Created
August 24, 2020 13:02
-
-
Save sam-ngu/6c4d527af205d43e2ff02ff93f342381 to your computer and use it in GitHub Desktop.
Parsing URL parameter name using Symfony Route.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$uri = 'https://test.com/api/users/{user}?page=4&size=5'; | |
$route = new SymfonyRoute( | |
preg_replace('/\{(\w+?)\?\}/', '{$1}', $uri), [], [], ['utf8' => true, 'action' => []], | |
'', [], [] | |
); | |
$compiled = $route->compile(); | |
// getting the variables as an array | |
$variables = $compiled->getVariables(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment