diff --git a/book/bundles.rst b/book/bundles.rst index ff09cc6fc3e..db7994795c2 100644 --- a/book/bundles.rst +++ b/book/bundles.rst @@ -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(), ); @@ -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 diff --git a/book/configuration.rst b/book/configuration.rst index da32a0e1afe..da96b334947 100644 --- a/book/configuration.rst +++ b/book/configuration.rst @@ -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:: @@ -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:: diff --git a/book/controller.rst b/book/controller.rst index cc7774d85b2..449e98b69e8 100644 --- a/book/controller.rst +++ b/book/controller.rst @@ -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``. diff --git a/book/doctrine.rst b/book/doctrine.rst index 87e894c1f45..e91ce4ec729 100644 --- a/book/doctrine.rst +++ b/book/doctrine.rst @@ -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 @@ -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 @@ -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 @@ -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 @@ -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:: @@ -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:: @@ -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, @@ -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)" @@ -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`` @@ -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:: diff --git a/book/http_cache.rst b/book/http_cache.rst index e01baff8c6d..8faf197fcf9 100644 --- a/book/http_cache.rst +++ b/book/http_cache.rst @@ -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 diff --git a/book/installation.rst b/book/installation.rst index 6e213203936..b222a06d4e2 100644 --- a/book/installation.rst +++ b/book/installation.rst @@ -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: @@ -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 ---------------------------------------------------- @@ -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. @@ -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** @@ -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. @@ -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 @@ -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. @@ -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. diff --git a/book/page_creation.rst b/book/page_creation.rst index c062182d5f8..dc763c45a76 100644 --- a/book/page_creation.rst +++ b/book/page_creation.rst @@ -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 { // ... @@ -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; @@ -168,8 +168,8 @@ at the end: .. code-block:: php-annotations // src/AppBundle/Controller/LuckyController.php - // ... + // ... class LuckyController extends Controller { /** @@ -192,7 +192,7 @@ at the end: .. code-block:: xml - + add this new use statement use Symfony\Bundle\FrameworkBundle\Controller\Controller; @@ -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 { /** @@ -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}") */ @@ -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 ` 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 @@ -475,8 +486,8 @@ is ``app/config/config.yml``: .. code-block:: yaml # app/config/config.yml - # ... + # ... framework: secret: "%secret%" router: @@ -544,11 +555,11 @@ by changing one option in this configuration file. To find out how, see the :doc:`Configuration Reference ` 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 diff --git a/book/performance.rst b/book/performance.rst index c73ed68c1ee..c60554015b8 100644 --- a/book/performance.rst +++ b/book/performance.rst @@ -75,16 +75,18 @@ If you're using the Standard Distribution, this code should already be available as comments in this file:: // app.php - // ... - - $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; - // Use APC for autoloading to improve performance - // Change 'sf2' by the prefix you want in order - // to prevent key conflict with another application + // ... + $loader = require __DIR__.'/../app/autoload.php'; + include_once __DIR__.'/../var/bootstrap.php.cache'; + // Enable APC for autoloading to improve performance. + // You should change the ApcClassLoader first argument to a unique prefix + // in order to prevent cache key conflicts with other applications + // also using APC. /* - $loader = new ApcClassLoader('sf2', $loader); - $loader->register(true); + $apcLoader = new Symfony\Component\ClassLoader\ApcClassLoader(sha1(__FILE__), $loader); + $loader->unregister(); + $apcLoader->register(true); */ // ... @@ -119,7 +121,7 @@ If you're using the Symfony Standard Edition, then you're probably already using the bootstrap file. To be sure, open your front controller (usually ``app.php``) and check to make sure that the following line exists:: - require_once __DIR__.'/../app/bootstrap.php.cache'; + include_once __DIR__.'/../var/bootstrap.php.cache'; Note that there are two disadvantages when using a bootstrap file: diff --git a/book/routing.rst b/book/routing.rst index b6107d12dfb..df27c4281a6 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -1401,7 +1401,7 @@ the command by running the following from the root of your project. .. code-block:: bash - $ php app/console debug:router + $ php bin/console debug:router .. versionadded:: 2.6 Prior to Symfony 2.6, this command was called ``router:debug``. @@ -1423,14 +1423,14 @@ the route name after the command: .. code-block:: bash - $ php app/console debug:router article_show + $ php bin/console debug:router article_show Likewise, if you want to test whether a URL matches a given route, you can use the ``router:match`` console command: .. code-block:: bash - $ php app/console router:match /blog/my-latest-post + $ php bin/console router:match /blog/my-latest-post This command will print which route the URL matches. diff --git a/book/security.rst b/book/security.rst index 094bb487bfe..5f410cac2ac 100644 --- a/book/security.rst +++ b/book/security.rst @@ -1363,7 +1363,7 @@ security vulnerability in your installed dependencies: .. 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. Internally, diff --git a/book/service_container.rst b/book/service_container.rst index 261c32b4183..56d43870e1d 100644 --- a/book/service_container.rst +++ b/book/service_container.rst @@ -1133,7 +1133,7 @@ console. To show all services and the class for each service, run: .. 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``. @@ -1142,7 +1142,7 @@ By default, only public services are shown, but you can also view private servic .. code-block:: bash - $ php app/console debug:container --show-private + $ php bin/console debug:container --show-private .. note:: @@ -1156,7 +1156,7 @@ its id: .. code-block:: bash - $ php app/console debug:container my_mailer + $ php bin/console debug:container my_mailer Learn more ---------- diff --git a/book/templating.rst b/book/templating.rst index f50085219c1..f66befd9f71 100644 --- a/book/templating.rst +++ b/book/templating.rst @@ -159,7 +159,7 @@ Twig Template Caching Twig is fast. Each Twig template is compiled down to a native PHP class that is rendered at runtime. The compiled classes are located in the -``app/cache/{environment}/twig`` directory (where ``{environment}`` is the +``var/cache/{environment}/twig`` directory (where ``{environment}`` is the environment, such as ``dev`` or ``prod``) and in some cases can be useful while debugging. See :ref:`environments-summary` for more information on environments. @@ -1218,7 +1218,7 @@ should use the ``parent()`` Twig function to include everything from the ``style block of the base template. You can also include assets located in your bundles' ``Resources/public`` folder. -You will need to run the ``php app/console assets:install target [--symlink]`` +You will need to run the ``php bin/console assets:install target [--symlink]`` command, which moves (or symlinks) files into the correct location. (target is by default "web"). @@ -1398,7 +1398,7 @@ to create it). You're now free to customize the template. .. caution:: If you add a template in a new location, you *may* need to clear your - cache (``php app/console cache:clear``), even if you are in debug mode. + cache (``php bin/console cache:clear``), even if you are in debug mode. This logic also applies to base bundle templates. Suppose also that each template in AcmeBlogBundle inherits from a base template called @@ -1648,10 +1648,10 @@ console command: .. code-block:: bash # You can check by filename: - $ php app/console lint:twig app/Resources/views/article/recent_list.html.twig + $ php bin/console lint:twig app/Resources/views/article/recent_list.html.twig # or by directory: - $ php app/console lint:twig app/Resources/views + $ php bin/console lint:twig app/Resources/views .. _template-formats: diff --git a/book/testing.rst b/book/testing.rst index 9dc85d4cba8..59d2c2c5428 100644 --- a/book/testing.rst +++ b/book/testing.rst @@ -28,11 +28,10 @@ command: .. code-block:: bash # specify the configuration directory on the command line - $ phpunit -c app/ + $ phpunit -The ``-c`` option tells PHPUnit to look in the ``app/`` directory for a configuration -file. If you're curious about the PHPUnit options, check out the ``app/phpunit.xml.dist`` -file. +PHPunit is configured by the ``phpunit.xml.dist`` file in the root of your +Symfony application. .. tip:: @@ -93,23 +92,23 @@ of your bundle:: Just like in your real application - autoloading is automatically enabled via the ``bootstrap.php.cache`` file (as configured by default in the -``app/phpunit.xml.dist`` file). +``phpunit.xml.dist`` file). Running tests for a given file or directory is also very easy: .. code-block:: bash # run all tests of the application - $ phpunit -c app + $ phpunit # run all tests in the Util directory - $ phpunit -c app src/AppBundle/Tests/Util + $ phpunit src/AppBundle/Tests/Util # run tests for the Calculator class - $ phpunit -c app src/AppBundle/Tests/Util/CalculatorTest.php + $ phpunit src/AppBundle/Tests/Util/CalculatorTest.php # run all tests for the entire Bundle - $ phpunit -c app src/AppBundle/ + $ phpunit src/AppBundle/ .. index:: single: Tests; Functional tests @@ -802,23 +801,23 @@ PHPUnit Configuration ~~~~~~~~~~~~~~~~~~~~~ Each application has its own PHPUnit configuration, stored in the -``app/phpunit.xml.dist`` file. You can edit this file to change the defaults or -create an ``app/phpunit.xml`` file to set up a configuration for your local -machine only. +``phpunit.xml.dist`` file. You can edit this file to change the defaults or +create an ``phpunit.xml`` file to set up a configuration for your local machine +only. .. tip:: - Store the ``app/phpunit.xml.dist`` file in your code repository and ignore - the ``app/phpunit.xml`` file. + Store the ``phpunit.xml.dist`` file in your code repository and ignore + the ``phpunit.xml`` file. By default, only the tests from your own custom bundles stored in the standard directories ``src/*/*Bundle/Tests``, ``src/*/Bundle/*Bundle/Tests``, ``src/*Bundle/Tests`` are run by the ``phpunit`` command, as configured -in the ``app/phpunit.xml.dist`` file: +in the ``phpunit.xml.dist`` file: .. code-block:: xml - + @@ -836,7 +835,7 @@ configuration adds tests from a custom ``lib/tests`` directory: .. code-block:: xml - + @@ -853,7 +852,7 @@ section: .. code-block:: xml - + diff --git a/book/translation.rst b/book/translation.rst index 7cd2fe0e8a9..3e02f2e65bf 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -387,7 +387,7 @@ For more options, see :ref:`component-translator-message-catalogs`. .. code-block:: bash - $ php app/console cache:clear + $ php bin/console cache:clear .. _book-translation-fallback: @@ -815,7 +815,7 @@ To inspect all messages in the ``fr`` locale for the AcmeDemoBundle, run: .. code-block:: bash - $ php app/console debug:translation fr AcmeDemoBundle + $ php bin/console debug:translation fr AcmeDemoBundle You will get this output: @@ -856,15 +856,15 @@ By default all domains are inspected, but it is possible to specify a single dom .. code-block:: bash - $ php app/console debug:translation en AcmeDemoBundle --domain=messages + $ php bin/console debug:translation en AcmeDemoBundle --domain=messages When bundles have a lot of messages, it is useful to display only the unused or only the missing messages, by using the ``--only-unused`` or ``--only-missing`` switches: .. code-block:: bash - $ php app/console debug:translation en AcmeDemoBundle --only-unused - $ php app/console debug:translation en AcmeDemoBundle --only-missing + $ php bin/console debug:translation en AcmeDemoBundle --only-unused + $ php bin/console debug:translation en AcmeDemoBundle --only-missing Summary -------