{"action":"created","issue":{"url":"https://api.github.com/repos/slimphp/Slim/issues/1289","labels_url":"https://api.github.com/repos/slimphp/Slim/issues/1289/labels{/name}","comments_url":"https://api.github.com/repos/slimphp/Slim/issues/1289/comments","events_url":"https://api.github.com/repos/slimphp/Slim/issues/1289/events","html_url":"https://github.com/slimphp/Slim/issues/1289","id":87904266,"number":1289,"title":"Optional parameter in url","user":{"login":"silentworks","id":79497,"avatar_url":"https://avatars.githubusercontent.com/u/79497?v=3","gravatar_id":"","url":"https://api.github.com/users/silentworks","html_url":"https://github.com/silentworks","followers_url":"https://api.github.com/users/silentworks/followers","following_url":"https://api.github.com/users/silentworks/following{/other_user}","gists_url":"https://api.github.com/users/silentworks/gists{/gist_id}","starred_url":"https://api.github.com/users/silentworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/silentworks/subscriptions","organizations_url":"https://api.github.com/users/silentworks/orgs","repos_url":"https://api.github.com/users/silentworks/repos","events_url":"https://api.github.com/users/silentworks/events{/privacy}","received_events_url":"https://api.github.com/users/silentworks/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/slimphp/Slim/labels/Slim%203","name":"Slim 3","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/slimphp/Slim/milestones/12","html_url":"https://github.com/slimphp/Slim/milestones/Version%203.0.0","labels_url":"https://api.github.com/repos/slimphp/Slim/milestones/12/labels","id":382879,"number":12,"title":"Version 3.0.0","description":"","creator":{"login":"codeguy","id":31677,"avatar_url":"https://avatars.githubusercontent.com/u/31677?v=3","gravatar_id":"","url":"https://api.github.com/users/codeguy","html_url":"https://github.com/codeguy","followers_url":"https://api.github.com/users/codeguy/followers","following_url":"https://api.github.com/users/codeguy/following{/other_user}","gists_url":"https://api.github.com/users/codeguy/gists{/gist_id}","starred_url":"https://api.github.com/users/codeguy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codeguy/subscriptions","organizations_url":"https://api.github.com/users/codeguy/orgs","repos_url":"https://api.github.com/users/codeguy/repos","events_url":"https://api.github.com/users/codeguy/events{/privacy}","received_events_url":"https://api.github.com/users/codeguy/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":80,"state":"open","created_at":"2013-07-20T18:57:07Z","updated_at":"2015-06-15T16:53:54Z","due_on":null,"closed_at":null},"comments":24,"created_at":"2015-06-13T01:53:24Z","updated_at":"2015-06-17T09:02:17Z","closed_at":null,"body":"Slim doesn't support optional parameters as the underlying routing engine doesn't support them.\r\n\r\nWe need:\r\n\r\n* Ability to specify optional parameters in the route path\r\n* Ability to generate urls via `urlFor` for routes that have optional parameters.\r\n\r\n\r\nThis was originally reported as:\r\n\r\nIt would seem it currently isn't possible to add an optional paramater in the url if you are using urlFor to get the url via a named route.\r\n\r\n```php\r\n$app->get('/test/{param1}[/{optional:[A-Za-z]}]')->setName('test');\r\n\r\n$app->getContainer()['router']->urlFor('test', ['param1' => 'World']);\r\n```\r\n\r\nThis will throw an error because urlFor method does not know how to handle optional regex. I saw another project using FastRoute and they handle it using this regex https://github.com/mrjgreen/phroute/blob/master/src/Phroute/RouteParser.php#L23-L29"},"comment":{"url":"https://api.github.com/repos/slimphp/Slim/issues/comments/112727994","html_url":"https://github.com/slimphp/Slim/issues/1289#issuecomment-112727994","issue_url":"https://api.github.com/repos/slimphp/Slim/issues/1289","id":112727994,"user":{"login":"akrabat","id":33135,"avatar_url":"https://avatars.githubusercontent.com/u/33135?v=3","gravatar_id":"","url":"https://api.github.com/users/akrabat","html_url":"https://github.com/akrabat","followers_url":"https://api.github.com/users/akrabat/followers","following_url":"https://api.github.com/users/akrabat/following{/other_user}","gists_url":"https://api.github.com/users/akrabat/gists{/gist_id}","starred_url":"https://api.github.com/users/akrabat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akrabat/subscriptions","organizations_url":"https://api.github.com/users/akrabat/orgs","repos_url":"https://api.github.com/users/akrabat/repos","events_url":"https://api.github.com/users/akrabat/events{/privacy}","received_events_url":"https://api.github.com/users/akrabat/received_events","type":"User","site_admin":false},"created_at":"2015-06-17T09:02:17Z","updated_at":"2015-06-17T09:02:17Z","body":"I've started looking at replacing FastRoute with Aura.Router.\r\n\r\nInitial work here: https://github.com/slimphp/Slim/compare/develop...akrabat:aura-router?expand=1\r\n\r\nTestbed that I'm using: https://gist.github.com/akrabat/66d04bb7a8be8082a53f\r\n\r\nI haven't looked at route groups yet, but Aura supports them [out of the box](https://github.com/auraphp/Aura.Router/tree/2.x#attaching-route-groups)\r\n\r\nThings that I know work:\r\n\r\n* Optional parameters\r\n* Middleware attached to routes\r\n\r\nBC breaks with Slim 3 so far:\r\n\r\n* `->setName()` is replaced by `$name` as last parameter as Aura.Router requires the name up front. (Null is allowed though, so I made `$name` an optional last parameter to `map()`, `get()`, `post()`, etc.)"}}