symfony:symfony_tutorial_notes:create_your_first_page_in_symfony
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
symfony:symfony_tutorial_notes:create_your_first_page_in_symfony [2015/09/15 03:41] – created mithat | symfony:symfony_tutorial_notes:create_your_first_page_in_symfony [2015/09/17 23:38] (current) – mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Create Your First Page in Symfony ====== | ====== Create Your First Page in Symfony ====== | ||
+ | ===== TL;DR ===== | ||
+ | * Controllers live in **'' | ||
+ | * Templates live in **'' | ||
+ | * Use annotation in controllers to specify routes. | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * **'' | ||
+ | * The main configuration file for bundles is **'' | ||
+ | |||
+ | <file php src/ | ||
+ | <?php | ||
+ | |||
+ | namespace AppBundle\Controller; | ||
+ | |||
+ | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
+ | use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; | ||
+ | use Symfony\Component\HttpFoundation\Response; | ||
+ | |||
+ | class LuckyController extends Controller | ||
+ | { | ||
+ | /** | ||
+ | * @Route("/ | ||
+ | */ | ||
+ | public function numberAction($count) | ||
+ | { | ||
+ | $numbers = array(); | ||
+ | for ($i = 0; $i < $count; $i++) { | ||
+ | $numbers[] = rand(0, 100); | ||
+ | } | ||
+ | $numbersList = implode(', | ||
+ | |||
+ | return $this-> | ||
+ | ' | ||
+ | ' | ||
+ | ] | ||
+ | ); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <file twig app/ | ||
+ | {% extends ' | ||
+ | {% block body %} | ||
+ | < | ||
+ | {% endblock %} | ||
+ | </ | ||
===== Creating a new route/ | ===== Creating a new route/ | ||
Line 50: | Line 97: | ||
</ | </ | ||
or | or | ||
- | <file php src/ | + | <file php src/ |
// ... | // ... | ||
// --> don't forget this new use statement | // --> don't forget this new use statement | ||
Line 74: | Line 121: | ||
===== Dynamic URL Patterns ===== | ===== Dynamic URL Patterns ===== | ||
- | <file php LuckyController.php> | + | <file php src/ |
/** | /** | ||
* @Route("/ | * @Route("/ | ||
Line 114: | Line 161: | ||
</ | </ | ||
- | Templates live in **'' | + | Templates live in **'' |
<file twig app/ | <file twig app/ |
symfony/symfony_tutorial_notes/create_your_first_page_in_symfony.1442288477.txt.gz · Last modified: 2015/09/15 03:41 by mithat