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
| Twig: | |
| {# src/Acme/ArticleBundle/Resources/Article/list.html.twig #} | |
| {% extends 'AcmeArticleBundle::layout.html.twig' %} | |
| {% block body %} | |
| <h1>Recent Articles<h1> | |
| {% for article in articles %} | |
| {% include 'AcmeArticleBundle:Article:articleDetails.html.twig' with {'article': article} %} | |
| {% endfor %} |
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
| List: | |
| app.security - The security context. | |
| app.user - The current user object. | |
| app.request - The request object. | |
| app.session - The session object. | |
| app.environment - The current environment (dev, prod, etc). | |
| app.debug - True if in debug mode. False otherwise. | |
| Twig: |
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
| Twig: | |
| {% if app.session.hasFlash('notice') %} | |
| <div class="flash-notice"> | |
| {{ app.session.flash('notice') }} | |
| </div> | |
| {% endif %} | |
| PHP: | |
| <?php if ($view['session']->hasFlash('notice')): ?> | |
| <div class="flash-notice"> |
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
| Twig: | |
| <a href="{{ path('_welcome') }}">Home</a> | |
| PHP: | |
| <a href="<?php echo $view['router']->generate('_welcome') ?>">Home</a> | |
| If more complicated route. | |
| Twig: |
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
| # list of available commands | |
| php app/console list | |
| # getting list of routes | |
| php app/console router:debug | |
| # getting list of services | |
| php app/console container:debug | |
| # regenerating assets dump file |
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 | |
| return $this->redirect($this->generateUrl('homepage')); |
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 | |
| $request = $this->getRequest(); | |
| $templating = $this->get('templating'); | |
| $router = $this->get('router'); | |
| $mailer = $this->get('mailer'); |
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, |
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 | |
| $response = $this->forward('AcmeHelloBundle:Hello:fancy', array( | |
| 'name' => $name, | |
| 'color' => 'green' | |
| )); |
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 | |
| // 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(); | |