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 app/console router:debug |
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 app/console container:debug |
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 app/console assetic:dump --env=prod --no-debug |
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
// Sometimes you want to be able to get the base path url for your project | |
// and also another times you just want to get the root folder where | |
// the symfony2 application is living. | |
// For the first one, the url base path you get it this way: | |
$this->get('request')->getBasePath(); | |
// So when loading a page with URL http://localhost/Symfony/web/app.php | |
// of a symfony2 project located at /var/www/Symfony/ you just get: |
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
$response = $this->forward('AcmeHelloBundle:Hello:fancy', array( | |
'name' => $name, | |
'color' => 'green' | |
)); |
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
$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'}); |
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
$request = $this->getRequest(); | |
$templating = $this->get('templating'); | |
$router = $this->get('router'); | |
$mailer = $this->get('mailer'); |
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
return $this->redirect($this->generateUrl('homepage')); |
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
$myVal = $this->container->getParameter('my_val'); |
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
Need to use Symfony\Component\HttpFoundation\Response and function like this: | |
public function testAction() { | |
$response = new Response(json_encode(**code_req_here**)); | |
return $response; | |
} | |
and set a route like so: |