Created
July 21, 2013 04:41
-
-
Save serapheem/6047504 to your computer and use it in GitHub Desktop.
Symfony2 - Generating and matching routes
This file contains hidden or 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 | |
| $params = $router->match('/blog/my-blog-post'); | |
| // array('slug' => 'my-blog-post', '_controller' => 'AcmeBlogBundle:Blog:show') | |
| $uri = $router->generate('blog_show', array('slug' => 'my-blog-post')); | |
| // /blog/my-blog-post | |
| ?> | |
| If the frontend of your application uses AJAX requests, | |
| you might want to be able to generate URLs in JavaScript based on your routing configuration. | |
| By using the FOSJsRoutingBundle, you can do exactly that: | |
| var url = Routing.generate('blog_show', { "slug": 'my-blog-post'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment