Skip to content

Commit dbf0d31

Browse files
committed
feature #5913 [3.0][Book] Use the 3.0 directory structure (WouterJ)
This PR was merged into the master branch. Discussion ---------- [3.0][Book] Use the 3.0 directory structure | Q | A | --- | --- | Doc fix? | yes | New docs? | yes | Applies to | 3.0+ | Fixed tickets | part of #5898 Commits ------- 25ae8c1 Applied suggestions ed43015 Prefix commands with 'php' 0d69414 Updating 'Exploring the Project' 6b5c977 app/bootstrap.php.cache -> var/bootstrap.php.cache 3318f2e app/(cache|logs) -> var/(cache|logs) 1461bdc app/phpunit.xml.dist -> phpunit.xml.dist 8794a4d app/console -> bin/console
2 parents 2daccc3 + 25ae8c1 commit dbf0d31

14 files changed

+108
-98
lines changed

book/bundles.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class::
107107
{
108108
$bundles = array(
109109
// ...
110+
110111
// register your bundle
111112
new Acme\TestBundle\AcmeTestBundle(),
112113
);
@@ -122,7 +123,7 @@ generating a basic bundle skeleton:
122123

123124
.. code-block:: bash
124125
125-
$ php app/console generate:bundle --namespace=Acme/TestBundle
126+
$ php bin/console generate:bundle --namespace=Acme/TestBundle
126127
127128
The bundle skeleton generates a basic controller, template and routing
128129
resource that can be customized. You'll learn more about Symfony's command-line

book/configuration.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ FrameworkBundle configuration:
122122

123123
.. code-block:: bash
124124
125-
$ app/console config:dump-reference FrameworkBundle
125+
$ php bin/console config:dump-reference FrameworkBundle
126126
127127
The extension alias (configuration key) can also be used:
128128

129129
.. code-block:: bash
130130
131-
$ app/console config:dump-reference framework
131+
$ php bin/console config:dump-reference framework
132132
133133
.. note::
134134

@@ -177,7 +177,7 @@ cached files and allow them to rebuild:
177177

178178
.. code-block:: bash
179179
180-
$ php app/console cache:clear --env=prod --no-debug
180+
$ php bin/console cache:clear --env=prod --no-debug
181181
182182
.. note::
183183

book/controller.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ console command:
532532

533533
.. code-block:: bash
534534
535-
$ php app/console debug:container
535+
$ php bin/console debug:container
536536
537537
.. versionadded:: 2.6
538538
Prior to Symfony 2.6, this command was called ``container:debug``.

book/doctrine.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ for you:
116116

117117
.. code-block:: bash
118118
119-
$ php app/console doctrine:database:create
119+
$ php bin/console doctrine:database:create
120120
121121
.. sidebar:: Setting up the Database to be UTF8
122122

@@ -128,8 +128,8 @@ for you:
128128

129129
.. code-block:: bash
130130
131-
$ php app/console doctrine:database:drop --force
132-
$ php app/console doctrine:database:create
131+
$ php bin/console doctrine:database:drop --force
132+
$ php bin/console doctrine:database:create
133133
134134
There's no way to configure these defaults inside Doctrine, as it tries to be
135135
as agnostic as possible in terms of environment configuration. One way to solve
@@ -227,7 +227,7 @@ just a simple PHP class.
227227

228228
.. code-block:: bash
229229
230-
$ php app/console doctrine:generate:entity
230+
$ php bin/console doctrine:generate:entity
231231
232232
.. index::
233233
single: Doctrine; Adding mapping metadata
@@ -392,7 +392,7 @@ a regular PHP class, you need to create getter and setter methods (e.g. ``getNam
392392

393393
.. code-block:: bash
394394
395-
$ php app/console doctrine:generate:entities AppBundle/Entity/Product
395+
$ php bin/console doctrine:generate:entities AppBundle/Entity/Product
396396
397397
This command makes sure that all the getters and setters are generated
398398
for the ``Product`` class. This is a safe command - you can run it over and
@@ -434,10 +434,10 @@ mapping information) of a bundle or an entire namespace:
434434
.. code-block:: bash
435435
436436
# generates all entities in the AppBundle
437-
$ php app/console doctrine:generate:entities AppBundle
437+
$ php bin/console doctrine:generate:entities AppBundle
438438
439439
# generates all entities of bundles in the Acme namespace
440-
$ php app/console doctrine:generate:entities Acme
440+
$ php bin/console doctrine:generate:entities Acme
441441
442442
.. note::
443443

@@ -459,7 +459,7 @@ in your application. To do this, run:
459459

460460
.. code-block:: bash
461461
462-
$ php app/console doctrine:schema:update --force
462+
$ php bin/console doctrine:schema:update --force
463463
464464
.. tip::
465465

@@ -852,7 +852,7 @@ used earlier to generate the missing getter and setter methods:
852852

853853
.. code-block:: bash
854854
855-
$ php app/console doctrine:generate:entities AppBundle
855+
$ php bin/console doctrine:generate:entities AppBundle
856856
857857
Next, add a new method - ``findAllOrderedByName()`` - to the newly generated
858858
repository class. This method will query for all the ``Product`` entities,
@@ -906,7 +906,7 @@ you can let Doctrine create the class for you.
906906

907907
.. code-block:: bash
908908
909-
$ php app/console doctrine:generate:entity --no-interaction \
909+
$ php bin/console doctrine:generate:entity --no-interaction \
910910
--entity="AppBundle:Category" \
911911
--fields="name:string(255)"
912912
@@ -1063,7 +1063,7 @@ methods for you:
10631063

10641064
.. code-block:: bash
10651065
1066-
$ php app/console doctrine:generate:entities AppBundle
1066+
$ php bin/console doctrine:generate:entities AppBundle
10671067
10681068
Ignore the Doctrine metadata for a moment. You now have two classes - ``Category``
10691069
and ``Product`` with a natural one-to-many relationship. The ``Category``
@@ -1092,7 +1092,7 @@ table, and ``product.category_id`` column, and new foreign key:
10921092

10931093
.. code-block:: bash
10941094
1095-
$ php app/console doctrine:schema:update --force
1095+
$ php bin/console doctrine:schema:update --force
10961096
10971097
.. note::
10981098

book/http_cache.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,9 @@ To enable caching, modify the code of a front controller to use the caching
145145
kernel::
146146

147147
// web/app.php
148-
require_once __DIR__.'/../app/bootstrap.php.cache';
149-
require_once __DIR__.'/../app/AppKernel.php';
150-
require_once __DIR__.'/../app/AppCache.php';
151-
152148
use Symfony\Component\HttpFoundation\Request;
153149

150+
// ...
154151
$kernel = new AppKernel('prod', false);
155152
$kernel->loadClassCache();
156153
// wrap the default AppKernel with the AppCache one

book/installation.rst

+13-13
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ browsing the project directory and executing this command:
166166
.. code-block:: bash
167167
168168
$ cd my_project_name/
169-
$ php app/console server:run
169+
$ php bin/console server:run
170170
171171
Then, open your browser and access the ``http://localhost:8000/`` URL to see the
172172
Welcome Page of Symfony:
@@ -197,7 +197,7 @@ server with the ``server:stop`` command:
197197

198198
.. code-block:: bash
199199
200-
$ php app/console server:stop
200+
$ php bin/console server:stop
201201
202202
Checking Symfony Application Configuration and Setup
203203
----------------------------------------------------
@@ -216,8 +216,8 @@ If there are any issues, correct them now before moving on.
216216

217217
.. sidebar:: Setting up Permissions
218218

219-
One common issue when installing Symfony is that the ``app/cache`` and
220-
``app/logs`` directories must be writable both by the web server and the
219+
One common issue when installing Symfony is that the ``var/cache`` and
220+
``var/logs`` directories must be writable both by the web server and the
221221
command line user. On a UNIX system, if your web server user is different
222222
from your command line user, you can try one of the following solutions.
223223

@@ -238,12 +238,12 @@ If there are any issues, correct them now before moving on.
238238

239239
.. code-block:: bash
240240
241-
$ rm -rf app/cache/*
242-
$ rm -rf app/logs/*
241+
$ rm -rf var/cache/*
242+
$ rm -rf var/logs/*
243243
244244
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
245-
$ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
246-
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
245+
$ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" var/cache var/logs
246+
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" var/cache var/logs
247247
248248
249249
**3. Using ACL on a system that does not support chmod +a**
@@ -257,8 +257,8 @@ If there are any issues, correct them now before moving on.
257257
.. code-block:: bash
258258
259259
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
260-
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
261-
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
260+
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var/cache var/logs
261+
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var/cache var/logs
262262
263263
If this doesn't work, try adding ``-n`` option.
264264

@@ -267,7 +267,7 @@ If there are any issues, correct them now before moving on.
267267
If none of the previous methods work for you, change the umask so that the
268268
cache and log directories will be group-writable or world-writable (depending
269269
if the web server user and the command line user are in the same group or not).
270-
To achieve this, put the following line at the beginning of the ``app/console``,
270+
To achieve this, put the following line at the beginning of the ``bin/console``,
271271
``web/app.php`` and ``web/app_dev.php`` files::
272272

273273
umask(0002); // This will let the permissions be 0775
@@ -308,7 +308,7 @@ several minutes to complete.
308308

309309
.. code-block:: bash
310310
311-
$ php app/console security:check
311+
$ php bin/console security:check
312312
313313
A good security practice is to execute this command regularly to be able to
314314
update or replace compromised dependencies as soon as possible.
@@ -333,7 +333,7 @@ of the Symfony Installer anywhere in your system:
333333
c:\projects\> php symfony demo
334334
335335
Once downloaded, enter into the ``symfony_demo/`` directory and run the PHP's
336-
built-in web server executing the ``php app/console server:run`` command. Access
336+
built-in web server executing the ``php bin/console server:run`` command. Access
337337
to the ``http://localhost:8000`` URL in your browser to start using the Symfony
338338
Demo application.
339339

book/page_creation.rst

+31-20
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ Suppose you want to create a JSON endpoint that returns the lucky number.
102102
Just add a second method to ``LuckyController``::
103103

104104
// src/AppBundle/Controller/LuckyController.php
105-
// ...
106105

106+
// ...
107107
class LuckyController extends Controller
108108
{
109109
// ...
@@ -132,8 +132,8 @@ Try this out in your browser:
132132
You can even shorten this with the handy :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`::
133133

134134
// src/AppBundle/Controller/LuckyController.php
135-
// ...
136135

136+
// ...
137137
// --> don't forget this new use statement
138138
use Symfony\Component\HttpFoundation\JsonResponse;
139139

@@ -168,8 +168,8 @@ at the end:
168168
.. code-block:: php-annotations
169169
170170
// src/AppBundle/Controller/LuckyController.php
171-
// ...
172171
172+
// ...
173173
class LuckyController extends Controller
174174
{
175175
/**
@@ -192,7 +192,7 @@ at the end:
192192
193193
.. code-block:: xml
194194
195-
<!-- src/Acme/DemoBundle/Resources/config/routing.xml -->
195+
<!-- app/config/routing.xml -->
196196
<?xml version="1.0" encoding="UTF-8" ?>
197197
<routes xmlns="http://symfony.com/schema/routing"
198198
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -206,7 +206,7 @@ at the end:
206206
207207
.. code-block:: php
208208
209-
// src/Acme/DemoBundle/Resources/config/routing.php
209+
// app/config/routing.php
210210
use Symfony\Component\Routing\RouteCollection;
211211
use Symfony\Component\Routing\Route;
212212
@@ -274,8 +274,8 @@ to use Twig - or many other tools in Symfony - is to extend Symfony's base
274274
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class::
275275

276276
// src/AppBundle/Controller/LuckyController.php
277-
// ...
278277

278+
// ...
279279
// --> add this new use statement
280280
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
281281

@@ -296,8 +296,8 @@ Twig templates, another that can log messages and many more.
296296
To render a Twig template, use a service called ``templating``::
297297

298298
// src/AppBundle/Controller/LuckyController.php
299-
// ...
300299

300+
// ...
301301
class LuckyController extends Controller
302302
{
303303
/**
@@ -329,8 +329,8 @@ But this can get even easier! By extending the ``Controller`` class, you
329329
also get a lot of shortcut methods, like ``render()``::
330330

331331
// src/AppBundle/Controller/LuckyController.php
332-
// ...
333332

333+
// ...
334334
/**
335335
* @Route("/lucky/number/{count}")
336336
*/
@@ -434,30 +434,41 @@ worked inside the two most important directories:
434434
else). As you get more advanced, you'll learn what can be done inside each
435435
of these.
436436

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
440439
PHP files in ``app/``).
441440

442441
The ``src/`` directory has just one directory - ``src/AppBundle`` -
443442
and everything lives inside of it. A bundle is like a "plugin" and you can
444443
`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
447446
why you might create multiple bundles (hint: sharing code between projects),
448447
see the :doc:`Bundles </book/bundles>` chapter.
449448

450449
So what about the other directories in the project?
451450

452-
``vendor/``
453-
Vendor (i.e. third-party) libraries and bundles are downloaded here by
454-
the `Composer`_ package manager.
455-
456451
``web/``
457452
This is the document root for the project and contains any publicly accessible
458453
files, like CSS, images and the Symfony front controllers that execute
459454
the app (``app_dev.php`` and ``app.php``).
460455

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+
461472
.. seealso::
462473

463474
Symfony is flexible. If you need to, you can easily override the default
@@ -475,8 +486,8 @@ is ``app/config/config.yml``:
475486
.. code-block:: yaml
476487
477488
# app/config/config.yml
478-
# ...
479489
490+
# ...
480491
framework:
481492
secret: "%secret%"
482493
router:
@@ -544,11 +555,11 @@ by changing one option in this configuration file. To find out how, see the
544555
:doc:`Configuration Reference </reference/index>` section.
545556

546557
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:
548559

549560
.. code-block:: bash
550561
551-
$ app/console config:dump-reference framework
562+
$ php bin/console config:dump-reference framework
552563
553564
There's a lot more power behind Symfony's configuration system, including
554565
environments, imports and parameters. To learn all of it, see the

0 commit comments

Comments
 (0)