Skip to content

Commit

Permalink
feature #5913 [3.0][Book] Use the 3.0 directory structure (WouterJ)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
weaverryan committed Nov 30, 2015
2 parents 2daccc3 + 25ae8c1 commit dbf0d31
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 98 deletions.
3 changes: 2 additions & 1 deletion book/bundles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class::
{
$bundles = array(
// ...

// register your bundle
new Acme\TestBundle\AcmeTestBundle(),
);
Expand All @@ -122,7 +123,7 @@ generating a basic bundle skeleton:

.. code-block:: bash
$ php app/console generate:bundle --namespace=Acme/TestBundle
$ php bin/console generate:bundle --namespace=Acme/TestBundle
The bundle skeleton generates a basic controller, template and routing
resource that can be customized. You'll learn more about Symfony's command-line
Expand Down
6 changes: 3 additions & 3 deletions book/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ FrameworkBundle configuration:

.. code-block:: bash
$ app/console config:dump-reference FrameworkBundle
$ php bin/console config:dump-reference FrameworkBundle
The extension alias (configuration key) can also be used:

.. code-block:: bash
$ app/console config:dump-reference framework
$ php bin/console config:dump-reference framework
.. note::

Expand Down Expand Up @@ -177,7 +177,7 @@ cached files and allow them to rebuild:

.. code-block:: bash
$ php app/console cache:clear --env=prod --no-debug
$ php bin/console cache:clear --env=prod --no-debug
.. note::

Expand Down
2 changes: 1 addition & 1 deletion book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ console command:

.. code-block:: bash
$ php app/console debug:container
$ php bin/console debug:container
.. versionadded:: 2.6
Prior to Symfony 2.6, this command was called ``container:debug``.
Expand Down
24 changes: 12 additions & 12 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ for you:

.. code-block:: bash
$ php app/console doctrine:database:create
$ php bin/console doctrine:database:create
.. sidebar:: Setting up the Database to be UTF8

Expand All @@ -128,8 +128,8 @@ for you:

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

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

.. code-block:: bash
$ php app/console doctrine:generate:entities AppBundle/Entity/Product
$ php bin/console doctrine:generate:entities AppBundle/Entity/Product
This command makes sure that all the getters and setters are generated
for the ``Product`` class. This is a safe command - you can run it over and
Expand Down Expand Up @@ -434,10 +434,10 @@ mapping information) of a bundle or an entire namespace:
.. code-block:: bash
# generates all entities in the AppBundle
$ php app/console doctrine:generate:entities AppBundle
$ php bin/console doctrine:generate:entities AppBundle
# generates all entities of bundles in the Acme namespace
$ php app/console doctrine:generate:entities Acme
$ php bin/console doctrine:generate:entities Acme
.. note::

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

.. code-block:: bash
$ php app/console doctrine:schema:update --force
$ php bin/console doctrine:schema:update --force
.. tip::

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

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

.. code-block:: bash
$ php app/console doctrine:generate:entity --no-interaction \
$ php bin/console doctrine:generate:entity --no-interaction \
--entity="AppBundle:Category" \
--fields="name:string(255)"
Expand Down Expand Up @@ -1063,7 +1063,7 @@ methods for you:

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

.. code-block:: bash
$ php app/console doctrine:schema:update --force
$ php bin/console doctrine:schema:update --force
.. note::

Expand Down
5 changes: 1 addition & 4 deletions book/http_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,9 @@ To enable caching, modify the code of a front controller to use the caching
kernel::

// web/app.php
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
require_once __DIR__.'/../app/AppCache.php';

use Symfony\Component\HttpFoundation\Request;

// ...
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
// wrap the default AppKernel with the AppCache one
Expand Down
26 changes: 13 additions & 13 deletions book/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ browsing the project directory and executing this command:
.. code-block:: bash
$ cd my_project_name/
$ php app/console server:run
$ php bin/console server:run
Then, open your browser and access the ``http://localhost:8000/`` URL to see the
Welcome Page of Symfony:
Expand Down Expand Up @@ -197,7 +197,7 @@ server with the ``server:stop`` command:

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

.. sidebar:: Setting up Permissions

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

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

.. code-block:: bash
$ rm -rf app/cache/*
$ rm -rf app/logs/*
$ rm -rf var/cache/*
$ rm -rf var/logs/*
$ 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`
$ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
$ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" var/cache var/logs
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" var/cache var/logs
**3. Using ACL on a system that does not support chmod +a**
Expand All @@ -257,8 +257,8 @@ If there are any issues, correct them now before moving on.
.. code-block:: bash
$ 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`
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var/cache var/logs
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var/cache var/logs
If this doesn't work, try adding ``-n`` option.

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

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

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

Expand Down
51 changes: 31 additions & 20 deletions book/page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ Suppose you want to create a JSON endpoint that returns the lucky number.
Just add a second method to ``LuckyController``::

// src/AppBundle/Controller/LuckyController.php
// ...

// ...
class LuckyController extends Controller
{
// ...
Expand Down Expand Up @@ -132,8 +132,8 @@ Try this out in your browser:
You can even shorten this with the handy :class:`Symfony\\Component\\HttpFoundation\\JsonResponse`::

// src/AppBundle/Controller/LuckyController.php
// ...

// ...
// --> don't forget this new use statement
use Symfony\Component\HttpFoundation\JsonResponse;

Expand Down Expand Up @@ -168,8 +168,8 @@ at the end:
.. code-block:: php-annotations
// src/AppBundle/Controller/LuckyController.php
// ...
// ...
class LuckyController extends Controller
{
/**
Expand All @@ -192,7 +192,7 @@ at the end:
.. code-block:: xml
<!-- src/Acme/DemoBundle/Resources/config/routing.xml -->
<!-- app/config/routing.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Expand All @@ -206,7 +206,7 @@ at the end:
.. code-block:: php
// src/Acme/DemoBundle/Resources/config/routing.php
// app/config/routing.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
Expand Down Expand Up @@ -274,8 +274,8 @@ to use Twig - or many other tools in Symfony - is to extend Symfony's base
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller` class::

// src/AppBundle/Controller/LuckyController.php
// ...

// ...
// --> add this new use statement
use Symfony\Bundle\FrameworkBundle\Controller\Controller;

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

// src/AppBundle/Controller/LuckyController.php
// ...

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

// src/AppBundle/Controller/LuckyController.php
// ...

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

The ``app/`` directory also holds a few other things, like the cache directory
``app/cache/``, the logs directory ``app/logs/`` and ``app/AppKernel.php``,
which you'll use to enable new bundles (and one of a *very* short list of
The ``app/`` directory also holds some other things, like ``app/AppKernel.php``,
which you'll use to enable new bundles (this is one of a *very* short list of
PHP files in ``app/``).

The ``src/`` directory has just one directory - ``src/AppBundle`` -
and everything lives inside of it. A bundle is like a "plugin" and you can
`find open source bundles`_ and install them into your project. But even
*your* code lives in a bundle - typically ``AppBundle`` (though there's
nothing special about ``AppBundle``). To find out more about bundles and
*your* code lives in a bundle - typically *AppBundle* (though there's
nothing special about AppBundle). To find out more about bundles and
why you might create multiple bundles (hint: sharing code between projects),
see the :doc:`Bundles </book/bundles>` chapter.

So what about the other directories in the project?

``vendor/``
Vendor (i.e. third-party) libraries and bundles are downloaded here by
the `Composer`_ package manager.

``web/``
This is the document root for the project and contains any publicly accessible
files, like CSS, images and the Symfony front controllers that execute
the app (``app_dev.php`` and ``app.php``).

``tests/``
The automatic tests (e.g. Unit tests) of your application live here.

``bin/``
The "binary" files live here. The most important one is the ``console``
file which is used to execute Symfony commands via the console.

``var/``
This is where automatically created files are stored, like cache files
(``var/cache/``) and logs (``var/logs/``).

``vendor/``
Third-party libraries, packages and bundles are downloaded here by
the `Composer`_ package manager. You should never edit something in this
directory.

.. seealso::

Symfony is flexible. If you need to, you can easily override the default
Expand All @@ -475,8 +486,8 @@ is ``app/config/config.yml``:
.. code-block:: yaml
# app/config/config.yml
# ...
# ...
framework:
secret: "%secret%"
router:
Expand Down Expand Up @@ -544,11 +555,11 @@ by changing one option in this configuration file. To find out how, see the
:doc:`Configuration Reference </reference/index>` section.

Or, to get a big example dump of all of the valid configuration under a key,
use the handy ``app/console`` command:
use the handy ``bin/console`` command:

.. code-block:: bash
$ app/console config:dump-reference framework
$ php bin/console config:dump-reference framework
There's a lot more power behind Symfony's configuration system, including
environments, imports and parameters. To learn all of it, see the
Expand Down
Loading

0 comments on commit dbf0d31

Please sign in to comment.