8000 minor #13981 Fixed the Quick Tour sample code to work just by copy an… · symfony/symfony-docs@0d246c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0d246c1

Browse files
committed
minor #13981 Fixed the Quick Tour sample code to work just by copy and paste. (okazy)
This PR was submitted for the master branch but it was merged into the 4.4 branch instead. Discussion ---------- Fixed the Quick Tour sample code to work just by copy and paste. Beginners try to imitate the code of the quick tour as it is, but it does not work as it is because there is no `<?php`. Those pages are for beginners, so it's better to work just by copy and paste. Commits ------- 8f3ff01 Fixed the quick tour sample code to work just by copy and paste.
2 parents ff401de + 8f3ff01 commit 0d246c1

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

quick_tour/flex_recipes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Thanks to Flex, after one command, you can start using Twig immediately:
7575

7676
.. code-block:: diff
7777
78+
<?php
7879
// src/Controller/DefaultController.php
7980
namespace App\Controller;
8081
@@ -153,6 +154,7 @@ Rich API Support
153154

154155
Are you building an API? You can already return JSON from any controller::
155156

157+
<?php
156158
// src/Controller/DefaultController.php
157159
namespace App\Controller;
158160

@@ -189,6 +191,7 @@ But like usual, we can immediately start using the new library. Want to create a
189191
rich API for a ``product`` table? Create a ``Product`` entity and give it the
190192
``@ApiResource()`` annotation::
191193

194+
<?php
192195
// src/Entity/Product.php
193196
namespace App\Entity;
194197

quick_tour/the_architecture.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Want a logging system? No problem:
2121
This installs and configures (via a recipe) the powerful `Monolog`_ library. To
2222
use the logger in a controller, add a new argument type-hinted with ``LoggerInterface``::
2323

24+
<?php
2425
// src/Controller/DefaultController.php
2526
namespace App\Controller;
2627

@@ -89,6 +90,7 @@ To keep your code organized, you can even create your own services! Suppose you
8990
want to generate a random greeting (e.g. "Hello", "Yo", etc). Instead of putting
9091
this code directly in your controller, create a new class::
9192

93+
<?php
9294
// src/GreetingGenerator.php
9395
namespace App;
9496

@@ -105,6 +107,7 @@ this code directly in your controller, create a new class::
105107

106108
Great! You can use this immediately in your controller::
107109

110+
<?php
108111
// src/Controller/DefaultController.php
109112
namespace App\Controller;
110113

@@ -135,6 +138,7 @@ difference is that it's done in the constructor:
135138

136139
.. code-block:: diff
137140
141+
<?php
138142
// src/GreetingGenerator.php
139143
+ use Psr\Log\LoggerInterface;
140144
@@ -167,6 +171,7 @@ by creating an event subscriber or a security voter for complex authorization
167171
rules. Let's add a new filter to Twig called ``greet``. How? Create a class
168172
that extends ``AbstractExtension``::
169173

174+
<?php
170175
// src/Twig/GreetExtension.php
171176
namespace App\Twig;
172177

quick_tour/the_big_picture.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ doesn't exist yet, so let's create it!
8080
In ``src/Controller``, create a new ``DefaultController`` class and an ``index``
8181
method inside::
8282

83+
<?php
8384
// src/Controller/DefaultController.php
8485
namespace App\Controller;
8586

@@ -115,6 +116,7 @@ like a wildcard that matches anything. And it gets better! Update the controller
115116

116117
.. code-block:: diff
117118
119+
<?php
118120
// src/Controller/DefaultController.php
119121
namespace App\Controller;
120122
@@ -153,6 +155,7 @@ Instead, add the route *right above* the controller method:
153155

154156
.. code-block:: diff
155157
158+
<?php
156159
// src/Controller/DefaultController.php
157160
namespace App\Controller;
158161
@@ -173,6 +176,7 @@ This works just like before! But by using annotations, the route and controller
173176
live right next to each other. Need another page? Add another route and method
174177
in ``DefaultController``::
175178

179+
<?php
176180
// src/Controller/DefaultController.php
177181
namespace App\Controller;
178182

0 commit comments

Comments
 (0)
0