@@ -102,8 +102,8 @@ Suppose you want to create a JSON endpoint that returns the lucky number.
102
102
Just add a second method to ``LuckyController ``::
103
103
104
104
// src/AppBundle/Controller/LuckyController.php
105
- // ...
106
105
106
+ // ...
107
107
class LuckyController extends Controller
108
108
{
109
109
// ...
@@ -132,8 +132,8 @@ Try this out in your browser:
132
132
You can even shorten this with the handy :class: `Symfony\\ Component\\ HttpFoundation\\ JsonResponse `::
133
133
134
134
// src/AppBundle/Controller/LuckyController.php
135
- // ...
136
135
136
+ // ...
137
137
// --> don't forget this new use statement
138
138
use Symfony\Component\HttpFoundation\JsonResponse;
139
139
@@ -168,8 +168,8 @@ at the end:
168
168
.. code-block :: php-annotations
169
169
170
170
// src/AppBundle/Controller/LuckyController.php
171
- // ...
172
171
172
+ // ...
173
173
class LuckyController extends Controller
174
174
{
175
175
/**
@@ -192,7 +192,7 @@ at the end:
192
192
193
193
.. code-block :: xml
194
194
195
- <!-- src/Acme/DemoBundle/Resources /config/routing.xml -->
195
+ <!-- app /config/routing.xml -->
196
196
<?xml version =" 1.0" encoding =" UTF-8" ?>
197
197
<routes xmlns =" http://symfony.com/schema/routing"
198
198
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -206,7 +206,7 @@ at the end:
206
206
207
207
.. code-block :: php
208
208
209
- // src/Acme/DemoBundle/Resources /config/routing.php
209
+ // app /config/routing.php
210
210
use Symfony\Component\Routing\RouteCollection;
211
211
use Symfony\Component\Routing\Route;
212
212
@@ -274,8 +274,8 @@ to use Twig - or many other tools in Symfony - is to extend Symfony's base
274
274
:class: `Symfony\\ Bundle\\ FrameworkBundle\\ Controller\\ Controller ` class::
275
275
276
276
// src/AppBundle/Controller/LuckyController.php
277
- // ...
278
277
278
+ // ...
279
279
// --> add this new use statement
280
280
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
281
281
@@ -296,8 +296,8 @@ Twig templates, another that can log messages and many more.
296
296
To render a Twig template, use a service called ``templating ``::
297
297
298
298
// src/AppBundle/Controller/LuckyController.php
299
- // ...
300
299
300
+ // ...
301
301
class LuckyController extends Controller
302
302
{
303
303
/**
@@ -329,8 +329,8 @@ But this can get even easier! By extending the ``Controller`` class, you
329
329
also get a lot of shortcut methods, like ``render() ``::
330
330
331
331
// src/AppBundle/Controller/LuckyController.php
332
- // ...
333
332
333
+ // ...
334
334
/**
335
335
* @Route("/lucky/number/{count}")
336
336
*/
@@ -434,30 +434,41 @@ worked inside the two most important directories:
434
434
else). As you get more advanced, you'll learn what can be done inside each
435
435
of these.
436
436
437
- The ``app/ `` directory also holds a few other things, like the cache directory
438
- ``app/cache/ ``, the logs directory ``app/logs/ `` and ``app/AppKernel.php ``,
439
- which you'll use to enable new bundles (and one of a *very * short list of
437
+ The ``app/ `` directory also holds some other things, like ``app/AppKernel.php ``,
438
+ which you'll use to enable new bundles (this is one of a *very * short list of
440
439
PHP files in ``app/ ``).
441
440
442
441
The ``src/ `` directory has just one directory - ``src/AppBundle `` -
443
442
and everything lives inside of it. A bundle is like a "plugin" and you can
444
443
`find open source bundles `_ and install them into your project. But even
445
- *your * code lives in a bundle - typically `` AppBundle `` (though there's
446
- nothing special about `` AppBundle `` ). To find out more about bundles and
444
+ *your * code lives in a bundle - typically * AppBundle * (though there's
445
+ nothing special about AppBundle). To find out more about bundles and
447
446
why you might create multiple bundles (hint: sharing code between projects),
448
447
see the :doc: `Bundles </book/bundles >` chapter.
449
448
450
449
So what about the other directories in the project?
451
450
452
- ``vendor/ ``
453
- Vendor (i.e. third-party) libraries and bundles are downloaded here by
454
- the `Composer `_ package manager.
455
-
456
451
``web/ ``
457
452
This is the document root for the project and contains any publicly accessible
458
453
files, like CSS, images and the Symfony front controllers that execute
459
454
the app (``app_dev.php `` and ``app.php ``).
460
455
456
+ ``tests/ ``
457
+ The automatic tests (e.g. Unit tests) of your application live here.
458
+
459
+ ``bin/ ``
460
+ The "binary" files live here. The most important one is the ``console ``
461
+ file which is used to execute Symfony commands via the console.
462
+
463
+ ``var/ ``
464
+ This is where automatically created files are stored, like cache files
465
+ (``var/cache/ ``) and logs (``var/logs/ ``).
466
+
467
+ ``vendor/ ``
468
+ Third-party libraries, packages and bundles are downloaded here by
469
+ the `Composer `_ package manager. You should never edit something in this
470
+ directory.
471
+
461
472
.. seealso ::
462
473
463
474
Symfony is flexible. If you need to, you can easily override the default
@@ -475,8 +486,8 @@ is ``app/config/config.yml``:
475
486
.. code-block :: yaml
476
487
477
488
# app/config/config.yml
478
- # ...
479
489
490
+ # ...
480
491
framework :
481
492
secret : " %secret%"
482
493
router :
@@ -544,11 +555,11 @@ by changing one option in this configuration file. To find out how, see the
544
555
:doc: `Configuration Reference </reference/index >` section.
545
556
546
557
Or, to get a big example dump of all of the valid configuration under a key,
547
- use the handy ``app /console `` command:
558
+ use the handy ``bin /console `` command:
548
559
549
560
.. code-block :: bash
550
561
551
- $ app /console config:dump-reference framework
562
+ $ php bin /console config:dump-reference framework
552
563
553
564
There's a lot more power behind Symfony's configuration system, including
554
565
environments, imports and parameters. To learn all of it, see the
0 commit comments