diff --git a/cookbook/assetic/asset_management.rst b/cookbook/assetic/asset_management.rst index af0055f5795..2972243e842 100644 --- a/cookbook/assetic/asset_management.rst +++ b/cookbook/assetic/asset_management.rst @@ -500,7 +500,7 @@ each time you deploy), you should run the following command: .. code-block:: bash - $ php app/console assetic:dump --env=prod --no-debug + $ php bin/console assetic:dump --env=prod --no-debug This will physically generate and write each file that you need (e.g. ``/js/abcd123.js``). If you update any of your assets, you'll need to run this again to regenerate @@ -542,7 +542,7 @@ need to dump them manually. To do so, run the following command: .. code-block:: bash - $ php app/console assetic:dump + $ php bin/console assetic:dump This physically writes all of the asset files you need for your ``dev`` environment. The big disadvantage is that you need to run this each time @@ -551,7 +551,7 @@ assets will be regenerated automatically *as they change*: .. code-block:: bash - $ php app/console assetic:watch + $ php bin/console assetic:watch The ``assetic:watch`` command was introduced in AsseticBundle 2.4. In prior versions, you had to use the ``--watch`` option of the ``assetic:dump`` diff --git a/cookbook/bundles/installation.rst b/cookbook/bundles/installation.rst index 1dd7e1f4d83..2b6f222fd57 100644 --- a/cookbook/bundles/installation.rst +++ b/cookbook/bundles/installation.rst @@ -108,14 +108,14 @@ via the ``config:dump-reference`` command: .. code-block:: bash - $ app/console config:dump-reference AsseticBundle + $ bin/console config:dump-reference AsseticBundle Instead of the full bundle name, you can also pass the short name used as the root of the bundle's configuration: .. code-block:: bash - $ app/console config:dump-reference assetic + $ bin/console config:dump-reference assetic The output will look like this: diff --git a/cookbook/configuration/apache_router.rst b/cookbook/configuration/apache_router.rst index a8b4f8a7c33..4e69b18a289 100644 --- a/cookbook/configuration/apache_router.rst +++ b/cookbook/configuration/apache_router.rst @@ -98,7 +98,7 @@ Now generate the mod_rewrite rules: .. code-block:: bash - $ php app/console router:dump-apache -e=prod --no-debug + $ php bin/console router:dump-apache -e=prod --no-debug Which should roughly output the following: @@ -145,7 +145,7 @@ to ``ApacheRequest`` in ``web/app.php``:: // web/app.php - require_once __DIR__.'/../app/bootstrap.php.cache'; + require_once __DIR__.'/../var/bootstrap.php.cache'; require_once __DIR__.'/../app/AppKernel.php'; // require_once __DIR__.'/../app/AppCache.php'; diff --git a/cookbook/configuration/configuration_organization.rst b/cookbook/configuration/configuration_organization.rst index 5473a4c06b1..d3a1fc85b2f 100644 --- a/cookbook/configuration/configuration_organization.rst +++ b/cookbook/configuration/configuration_organization.rst @@ -34,8 +34,9 @@ default Symfony Standard Edition follow this structure: .. code-block:: text - / + your-project/ ├─ app/ + │ ├─ ... │ └─ config/ │ ├─ config.yml │ ├─ config_dev.yml @@ -46,9 +47,7 @@ default Symfony Standard Edition follow this structure: │ ├─ routing.yml │ ├─ routing_dev.yml │ └─ security.yml - ├─ src/ - ├─ vendor/ - └─ web/ + ├─ ... This default structure was chosen for its simplicity — one file per environment. But as any other Symfony feature, you can customize it to better suit your needs. @@ -65,8 +64,9 @@ name as the environment: .. code-block:: text - / + your-project/ ├─ app/ + │ ├─ ... │ └─ config/ │ ├─ common/ │ │ ├─ config.yml @@ -83,9 +83,7 @@ name as the environment: │ ├─ parameters.yml │ ├─ routing.yml │ └─ security.yml - ├─ src/ - ├─ vendor/ - └─ web/ + ├─ ... To make this work, change the code of the :method:`Symfony\\Component\\HttpKernel\\KernelInterface::registerContainerConfiguration` @@ -161,8 +159,9 @@ and several files to define all application services: .. code-block:: text - / + your-project/ ├─ app/ + │ ├─ ... │ └─ config/ │ ├─ bundles/ │ │ ├─ bundle1.yml @@ -182,9 +181,7 @@ and several files to define all application services: │ ├─ backend.yml │ ├─ ... │ └─ security.yml - ├─ src/ - ├─ vendor/ - └─ web/ + ├─ ... Again, change the code of the ``registerContainerConfiguration()`` method to make Symfony aware of the new file organization:: diff --git a/cookbook/configuration/environments.rst b/cookbook/configuration/environments.rst index a7b3ac22ba3..e43f07d6b46 100644 --- a/cookbook/configuration/environments.rst +++ b/cookbook/configuration/environments.rst @@ -221,13 +221,13 @@ behavior: .. code-block:: bash # 'dev' environment and debug enabled - $ php app/console command_name + $ php bin/console command_name # 'prod' environment (debug is always disabled for 'prod') - $ php app/console command_name --env=prod + $ php bin/console command_name --env=prod # 'test' environment and debug disabled - $ php app/console command_name --env=test --no-debug + $ php bin/console command_name --env=test --no-debug In addition to the ``--env`` and ``--debug`` options, the behavior of Symfony commands can also be controlled with environment variables. The Symfony console @@ -342,13 +342,13 @@ Symfony takes advantage of caching in many ways: the application configuration, routing configuration, Twig templates and more are cached to PHP objects stored in files on the filesystem. -By default, these cached files are largely stored in the ``app/cache`` directory. +By default, these cached files are largely stored in the ``var/cache`` directory. However, each environment caches its own set of files: .. code-block:: text - / - ├─ app/ + your-project/ + ├─ var/ │ ├─ cache/ │ │ ├─ dev/ # cache directory for the *dev* environment │ │ └─ prod/ # cache directory for the *prod* environment @@ -357,7 +357,7 @@ However, each environment caches its own set of files: Sometimes, when debugging, it may be helpful to inspect a cached file to understand how something is working. When doing so, remember to look in the directory of the environment you're using (most commonly ``dev`` while -developing and debugging). While it can vary, the ``app/cache/dev`` directory +developing and debugging). While it can vary, the ``var/cache/dev`` directory includes the following: ``appDevDebugProjectContainer.php`` diff --git a/cookbook/configuration/front_controllers_and_kernel.rst b/cookbook/configuration/front_controllers_and_kernel.rst index cab5f41b427..9bfe3be4e46 100644 --- a/cookbook/configuration/front_controllers_and_kernel.rst +++ b/cookbook/configuration/front_controllers_and_kernel.rst @@ -75,7 +75,7 @@ as the default one. access. For example, you don't want to make a debugging environment available to arbitrary users in your production environment. -Technically, the `app/console`_ script used when running Symfony on the command +Technically, the `bin/console`_ script used when running Symfony on the command line is also a front controller, only that is not used for web, but for command line requests. @@ -162,7 +162,7 @@ way of loading your configuration. .. _Symfony Standard Edition: https://github.com/symfony/symfony-standard .. _app.php: https://github.com/symfony/symfony-standard/blob/master/web/app.php .. _app_dev.php: https://github.com/symfony/symfony-standard/blob/master/web/app_dev.php -.. _app/console: https://github.com/symfony/symfony-standard/blob/master/app/console +.. _bin/console: https://github.com/symfony/symfony-standard/blob/master/bin/console .. _AppKernel: https://github.com/symfony/symfony-standard/blob/master/app/AppKernel.php .. _decorate: https://en.wikipedia.org/wiki/Decorator_pattern .. _RewriteRule shipped with the Symfony Standard Edition: https://github.com/symfony/symfony-standard/blob/master/web/.htaccess diff --git a/cookbook/configuration/override_dir_structure.rst b/cookbook/configuration/override_dir_structure.rst index d387a7931fa..5982d2bf80e 100644 --- a/cookbook/configuration/override_dir_structure.rst +++ b/cookbook/configuration/override_dir_structure.rst @@ -12,12 +12,16 @@ directory structure is: your-project/ ├─ app/ - │ ├─ cache/ │ ├─ config/ - │ ├─ logs/ │ └─ ... ├─ src/ │ └─ ... + ├─ tests/ + │ └─ ... + ├─ var/ + │ ├─ cache/ + │ ├─ logs/ + │ └─ ... ├─ vendor/ │ └─ ... └─ web/ @@ -41,13 +45,13 @@ in the ``AppKernel`` class of you application:: public function getCacheDir() { - return $this->rootDir.'/'.$this->environment.'/cache'; + return dirname(__DIR__).'/var/'.$this->environment.'/cache'; } } -``$this->rootDir`` is the absolute path to the ``app`` directory and ``$this->environment`` -is the current environment (i.e. ``dev``). In this case you have changed -the location of the cache directory to ``app/{environment}/cache``. +In this code, ``$this->environment`` is the current environment (i.e. ``dev``). +In this case you have changed the location of the cache directory to +``var/{environment}/cache``. .. caution:: @@ -74,11 +78,11 @@ method:: public function getLogDir() { - return $this->rootDir.'/'.$this->environment.'/logs'; + return dirname(__DIR__).'/var/'.$this->environment.'/logs'; } } -Here you have changed the location of the directory to ``app/{environment}/logs``. +Here you have changed the location of the directory to ``var/{environment}/logs``. .. _override-web-dir: @@ -86,23 +90,22 @@ Override the ``web`` Directory ------------------------------ If you need to rename or move your ``web`` directory, the only thing you -need to guarantee is that the path to the ``app`` directory is still correct +need to guarantee is that the path to the ``var`` directory is still correct in your ``app.php`` and ``app_dev.php`` front controllers. If you simply renamed the directory, you're fine. But if you moved it in some way, you may need to modify these paths inside those files:: - require_once __DIR__.'/../Symfony/app/bootstrap.php.cache'; - require_once __DIR__.'/../Symfony/app/AppKernel.php'; + require_once __DIR__.'/../path/to/var/bootstrap.php.cache'; -You also need to change the ``extra.symfony-web-dir`` option in the ``composer.json`` -file: +You also need to change the ``extra.symfony-web-dir`` option in the +``composer.json`` file: -.. code-block:: javascript +.. code-block:: json { - ... + "...": "...", "extra": { - ... + "...": "...", "symfony-web-dir": "my_new_web_dir" } } @@ -154,8 +157,8 @@ file: .. code-block:: bash - $ php app/console cache:clear --env=prod - $ php app/console assetic:dump --env=prod --no-debug + $ php bin/console cache:clear --env=prod + $ php bin/console assetic:dump --env=prod --no-debug Override the ``vendor`` Directory --------------------------------- @@ -179,6 +182,7 @@ The change in the ``composer.json`` will look like this: Then, update the path to the ``autoload.php`` file in ``app/autoload.php``:: // app/autoload.php + // ... $loader = require '/some/dir/vendor/autoload.php'; diff --git a/cookbook/console/console_command.rst b/cookbook/console/console_command.rst index 7e23a4762a4..2069aaa361b 100644 --- a/cookbook/console/console_command.rst +++ b/cookbook/console/console_command.rst @@ -68,7 +68,7 @@ This command will now automatically be available to run: .. code-block:: bash - $ php app/console demo:greet Fabien + $ php bin/console demo:greet Fabien .. _cookbook-console-dic: diff --git a/cookbook/console/logging.rst b/cookbook/console/logging.rst index 08781d7901b..4b2c83a0c6d 100644 --- a/cookbook/console/logging.rst +++ b/cookbook/console/logging.rst @@ -65,7 +65,7 @@ container and use it to do the logging:: } Depending on the environment in which you run your command (and your logging -setup), you should see the logged entries in ``app/logs/dev.log`` or ``app/logs/prod.log``. +setup), you should see the logged entries in ``var/logs/dev.log`` or ``var/logs/prod.log``. Enabling automatic Exceptions Logging ------------------------------------- diff --git a/cookbook/console/usage.rst b/cookbook/console/usage.rst index 0e2c1e5befd..8bdd134913e 100644 --- a/cookbook/console/usage.rst +++ b/cookbook/console/usage.rst @@ -17,13 +17,13 @@ clear and warm the ``prod`` cache you need to run: .. code-block:: bash - $ php app/console cache:clear --env=prod + $ php bin/console cache:clear --env=prod or the equivalent: .. code-block:: bash - $ php app/console cache:clear -e prod + $ php bin/console cache:clear -e prod In addition to changing the environment, you can also choose to disable debug mode. This can be useful where you want to run commands in the ``dev`` environment @@ -31,4 +31,4 @@ but avoid the performance hit of collecting debug data: .. code-block:: bash - $ php app/console list --no-debug + $ php bin/console list --no-debug diff --git a/cookbook/debugging.rst b/cookbook/debugging.rst index 98fae25bad8..2333bd65665 100644 --- a/cookbook/debugging.rst +++ b/cookbook/debugging.rst @@ -30,22 +30,21 @@ The ``app_dev.php`` front controller reads as follows by default:: // ... - $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; - require_once __DIR__.'/../app/AppKernel.php'; + $loader = require __DIR__.'/../app/autoload.php'; + Debug::enable(); $kernel = new AppKernel('dev', true); $kernel->loadClassCache(); $request = Request::createFromGlobals(); + // ... -To make your debugger happier, disable all PHP class caches by removing the -call to ``loadClassCache()`` and by replacing the require statements like -below:: +To make your debugger happier, disable all PHP class caches by removing (or +commenting) the call to ``loadClassCache()``:: // ... - // $loader = require_once __DIR__.'/../app/bootstrap.php.cache'; $loader = require_once __DIR__.'/../app/autoload.php'; - require_once __DIR__.'/../app/AppKernel.php'; + Debug::enable(); $kernel = new AppKernel('dev', true); // $kernel->loadClassCache(); diff --git a/cookbook/deployment/azure-website.rst b/cookbook/deployment/azure-website.rst index e24ed31409e..c13d8afc2ec 100644 --- a/cookbook/deployment/azure-website.rst +++ b/cookbook/deployment/azure-website.rst @@ -260,12 +260,12 @@ directory with at least the following contents: .. code-block:: text /app/bootstrap.php.cache - /app/cache/* + /var/cache/* /app/config/parameters.yml - /app/logs/* - !app/cache/.gitkeep - !app/logs/.gitkeep - /app/SymfonyRequirements.php + /var/logs/* + !var/cache/.gitkeep + !var/logs/.gitkeep + /var/SymfonyRequirements.php /build/ /vendor/ /bin/ @@ -388,7 +388,7 @@ MySQL database. .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force This command builds the tables and indexes for your MySQL database. If your Symfony application is more complex than a basic Symfony Standard Edition, you diff --git a/cookbook/deployment/heroku.rst b/cookbook/deployment/heroku.rst index 62ca1be4365..b61c923c891 100644 --- a/cookbook/deployment/heroku.rst +++ b/cookbook/deployment/heroku.rst @@ -275,7 +275,7 @@ This is also very useful to build assets on the production system, e.g. with Ass { "scripts": { "compile": [ - "app/console assetic:dump" + "bin/console assetic:dump" ] } } diff --git a/cookbook/deployment/platformsh.rst b/cookbook/deployment/platformsh.rst index 7b679177feb..9ca118f197e 100644 --- a/cookbook/deployment/platformsh.rst +++ b/cookbook/deployment/platformsh.rst @@ -62,16 +62,16 @@ Platform.sh how to deploy your application (read more about # The mounts that will be performed when the package is deployed. mounts: - "/app/cache": "shared:files/cache" + "/var/cache": "shared:files/cache" "/app/logs": "shared:files/logs" # The hooks that will be performed when the package is deployed. hooks: build: | rm web/app_dev.php - app/console --env=prod assetic:dump --no-debug + bin/console --env=prod assetic:dump --no-debug deploy: | - app/console --env=prod cache:clear + bin/console --env=prod cache:clear For best practices, you should also add a ``.platform`` folder at the root of your Git repository which contains the following files: diff --git a/cookbook/deployment/tools.rst b/cookbook/deployment/tools.rst index c53ed2fa6a5..cf6c3186e1f 100644 --- a/cookbook/deployment/tools.rst +++ b/cookbook/deployment/tools.rst @@ -150,7 +150,7 @@ Make sure you clear (and warm-up) your Symfony cache: .. code-block:: bash - $ php app/console cache:clear --env=prod --no-debug + $ php bin/console cache:clear --env=prod --no-debug E) Dump your Assetic Assets ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -159,7 +159,7 @@ If you're using Assetic, you'll also want to dump your assets: .. code-block:: bash - $ php app/console assetic:dump --env=prod --no-debug + $ php bin/console assetic:dump --env=prod --no-debug F) Other Things! ~~~~~~~~~~~~~~~~ diff --git a/cookbook/doctrine/console.rst b/cookbook/doctrine/console.rst index 0cfb7befca0..11459a3b2d5 100644 --- a/cookbook/doctrine/console.rst +++ b/cookbook/doctrine/console.rst @@ -11,7 +11,7 @@ command: .. code-block:: bash - $ php app/console list doctrine + $ php bin/console list doctrine A list of available commands will print out. You can find out more information about any of these commands (or any Symfony command) by running the ``help`` @@ -20,7 +20,7 @@ task, run: .. code-block:: bash - $ php app/console help doctrine:database:create + $ php bin/console help doctrine:database:create Some notable or interesting tasks include: @@ -30,7 +30,7 @@ Some notable or interesting tasks include: .. code-block:: bash - $ php app/console doctrine:ensure-production-settings --env=prod + $ php bin/console doctrine:ensure-production-settings --env=prod * ``doctrine:mapping:import`` - allows Doctrine to introspect an existing database and create mapping information. For more information, see diff --git a/cookbook/doctrine/multiple_entity_managers.rst b/cookbook/doctrine/multiple_entity_managers.rst index 5434d847365..484809aad4c 100644 --- a/cookbook/doctrine/multiple_entity_managers.rst +++ b/cookbook/doctrine/multiple_entity_managers.rst @@ -165,20 +165,20 @@ When working with multiple connections to create your databases: .. code-block:: bash # Play only with "default" connection - $ php app/console doctrine:database:create + $ php bin/console doctrine:database:create # Play only with "customer" connection - $ php app/console doctrine:database:create --connection=customer + $ php bin/console doctrine:database:create --connection=customer When working with multiple entity managers to update your schema: .. code-block:: bash # Play only with "default" mappings - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force # Play only with "customer" mappings - $ php app/console doctrine:schema:update --force --em=customer + $ php bin/console doctrine:schema:update --force --em=customer If you *do* omit the entity manager's name when asking for it, the default entity manager (i.e. ``default``) is returned:: diff --git a/cookbook/doctrine/registration_form.rst b/cookbook/doctrine/registration_form.rst index 062969242c1..9e31f9eded9 100644 --- a/cookbook/doctrine/registration_form.rst +++ b/cookbook/doctrine/registration_form.rst @@ -322,7 +322,7 @@ database schema using this command: .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force That's it! Head to ``/register`` to try things out! diff --git a/cookbook/doctrine/reverse_engineering.rst b/cookbook/doctrine/reverse_engineering.rst index dd50a6be9c2..efa393a0beb 100644 --- a/cookbook/doctrine/reverse_engineering.rst +++ b/cookbook/doctrine/reverse_engineering.rst @@ -59,7 +59,7 @@ table fields. .. code-block:: bash - $ php app/console doctrine:mapping:import --force AcmeBlogBundle xml + $ php bin/console doctrine:mapping:import --force AcmeBlogBundle xml This command line tool asks Doctrine to introspect the database and generate the XML metadata files under the ``src/Acme/BlogBundle/Resources/config/doctrine`` @@ -92,8 +92,8 @@ entity classes by executing the following two commands. .. code-block:: bash - $ php app/console doctrine:mapping:convert annotation ./src - $ php app/console doctrine:generate:entities AcmeBlogBundle + $ php bin/console doctrine:mapping:convert annotation ./src + $ php bin/console doctrine:generate:entities AcmeBlogBundle The first command generates entity classes with annotation mappings. But if you want to use YAML or XML mapping instead of annotations, you should diff --git a/cookbook/email/spool.rst b/cookbook/email/spool.rst index 3747f421f81..d8b897c9619 100644 --- a/cookbook/email/spool.rst +++ b/cookbook/email/spool.rst @@ -117,19 +117,19 @@ There is a console command to send the messages in the spool: .. code-block:: bash - $ php app/console swiftmailer:spool:send --env=prod + $ php bin/console swiftmailer:spool:send --env=prod It has an option to limit the number of messages to be sent: .. code-block:: bash - $ php app/console swiftmailer:spool:send --message-limit=10 --env=prod + $ php bin/console swiftmailer:spool:send --message-limit=10 --env=prod You can also set the time limit in seconds: .. code-block:: bash - $ php app/console swiftmailer:spool:send --time-limit=10 --env=prod + $ php bin/console swiftmailer:spool:send --time-limit=10 --env=prod Of course you will not want to run this manually in reality. Instead, the console command should be triggered by a cron job or scheduled task and run diff --git a/cookbook/email/testing.rst b/cookbook/email/testing.rst index 270f7506895..6ab1e522e7e 100644 --- a/cookbook/email/testing.rst +++ b/cookbook/email/testing.rst @@ -33,7 +33,9 @@ Start with an easy controller action that sends an email:: In your functional test, use the ``swiftmailer`` collector on the profiler to get information about the messages sent on the previous request:: - // src/AppBundle/Tests/Controller/MailControllerTest.php + // tests/AppBundle/Controller/MailControllerTest.php + namespace Tests\AppBundle\Controller; + use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; class MailControllerTest extends WebTestCase diff --git a/cookbook/event_dispatcher/event_listener.rst b/cookbook/event_dispatcher/event_listener.rst index 19ceebf755f..ecdcada660b 100644 --- a/cookbook/event_dispatcher/event_listener.rst +++ b/cookbook/event_dispatcher/event_listener.rst @@ -274,11 +274,11 @@ using the console. To show all events and their listeners, run: .. code-block:: bash - $ php app/console debug:event-dispatcher + $ php bin/console debug:event-dispatcher You can get registered listeners for a particular event by specifying its name: .. code-block:: bash - $ php app/console debug:event-dispatcher kernel.exception + $ php bin/console debug:event-dispatcher kernel.exception diff --git a/cookbook/form/unit_testing.rst b/cookbook/form/unit_testing.rst index e27d944cb7e..3a082dfd49f 100644 --- a/cookbook/form/unit_testing.rst +++ b/cookbook/form/unit_testing.rst @@ -36,8 +36,8 @@ The Basics The simplest ``TypeTestCase`` implementation looks like the following:: - // src/AppBundle/Tests/Form/Type/TestedTypeTest.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTest.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -117,15 +117,18 @@ might look like this:: // src/AppBundle/Form/Type/TestedType.php - // ... the buildForm method - $builder->add('app_test_child_type'); + // ... + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder->add('app_test_child_type'); + } To create your form correctly, you need to make the type available to the form factory in your test. The easiest way is to register it manually before creating the parent form using the ``PreloadedExtension`` class:: - // src/AppBundle/Tests/Form/Type/TestedTypeTests.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTests.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -158,7 +161,7 @@ before creating the parent form using the ``PreloadedExtension`` class:: be getting errors that are not related to the form you are currently testing but to its children. -Adding custom Extensions +Adding Custom Extensions ------------------------ It often happens that you use some options that are added by @@ -168,8 +171,8 @@ The ``TypeTestCase`` loads only the core form extension so an "Invalid option" exception will be raised if you try to use it for testing a class that depends on other extensions. You need to add those extensions to the factory object:: - // src/AppBundle/Tests/Form/Type/TestedTypeTests.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTests.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -217,8 +220,8 @@ Testing against different Sets of Data If you are not familiar yet with PHPUnit's `data providers`_, this might be a good opportunity to use them:: - // src/AppBundle/Tests/Form/Type/TestedTypeTests.php - namespace AppBundle\Tests\Form\Type; + // tests/AppBundle/Form/Type/TestedTypeTests.php + namespace Tests\AppBundle\Form\Type; use AppBundle\Form\Type\TestedType; use AppBundle\Model\TestObject; @@ -226,7 +229,6 @@ a good opportunity to use them:: class TestedTypeTest extends TypeTestCase { - /** * @dataProvider getValidTestData */ diff --git a/cookbook/logging/monolog.rst b/cookbook/logging/monolog.rst index 28db626cda6..c4e5c3d9a7f 100644 --- a/cookbook/logging/monolog.rst +++ b/cookbook/logging/monolog.rst @@ -39,8 +39,8 @@ to write the logs (the handlers can be shared). the logger will log to. The basic handler is the ``StreamHandler`` which writes logs in a stream -(by default in the ``app/logs/prod.log`` in the prod environment and -``app/logs/dev.log`` in the dev environment). +(by default in the ``var/logs/prod.log`` in the prod environment and +``var/logs/dev.log`` in the dev environment). Monolog comes also with a powerful built-in handler for the logging in prod environment: ``FingersCrossedHandler``. It allows you to store the diff --git a/cookbook/profiler/profiling_data.rst b/cookbook/profiler/profiling_data.rst index 761dae943e6..bb87bbf8cd7 100644 --- a/cookbook/profiler/profiling_data.rst +++ b/cookbook/profiler/profiling_data.rst @@ -53,10 +53,10 @@ one where the information was generated, use the ``profiler:export`` and .. code-block:: bash # on the production machine - $ php app/console profiler:export > profile.data + $ php bin/console profiler:export > profile.data # on the development machine - $ php app/console profiler:import /path/to/profile.data + $ php bin/console profiler:import /path/to/profile.data # you can also pipe from the STDIN - $ cat /path/to/profile.data | php app/console profiler:import + $ cat /path/to/profile.data | php bin/console profiler:import diff --git a/cookbook/security/acl.rst b/cookbook/security/acl.rst index b881393d91b..df3b936b3f0 100644 --- a/cookbook/security/acl.rst +++ b/cookbook/security/acl.rst @@ -96,7 +96,7 @@ Fortunately, there is a task for this. Simply run the following command: .. code-block:: bash - $ php app/console init:acl + $ php bin/console init:acl Getting Started --------------- diff --git a/cookbook/security/entity_provider.rst b/cookbook/security/entity_provider.rst index 58acf646245..1cb4db24bd3 100644 --- a/cookbook/security/entity_provider.rst +++ b/cookbook/security/entity_provider.rst @@ -145,13 +145,13 @@ by running: .. code-block:: bash - $ php app/console doctrine:generate:entities AppBundle/Entity/User + $ php bin/console doctrine:generate:entities AppBundle/Entity/User Next, make sure to :ref:`create the database table `: .. code-block:: bash - $ php app/console doctrine:schema:update --force + $ php bin/console doctrine:schema:update --force What's this UserInterface? ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/cookbook/testing/bootstrap.rst b/cookbook/testing/bootstrap.rst index aecbaff6c94..1f3c5464e41 100644 --- a/cookbook/testing/bootstrap.rst +++ b/cookbook/testing/bootstrap.rst @@ -19,12 +19,12 @@ First, add the following file:: require __DIR__.'/bootstrap.php.cache'; -Replace the test bootstrap file ``bootstrap.php.cache`` in ``app/phpunit.xml.dist`` +Replace the test bootstrap file ``bootstrap.php.cache`` in ``phpunit.xml.dist`` with ``tests.bootstrap.php``: .. code-block:: xml - + + diff --git a/cookbook/testing/database.rst b/cookbook/testing/database.rst index 04c8d07ee48..405a329f4e1 100644 --- a/cookbook/testing/database.rst +++ b/cookbook/testing/database.rst @@ -33,6 +33,7 @@ class. Suppose the class you want to test looks like this:: + // src/AppBundle/Salary/SalaryCalculator.php namespace AppBundle\Salary; use Doctrine\Common\Persistence\ObjectManager; @@ -59,14 +60,20 @@ Suppose the class you want to test looks like this:: Since the ``ObjectManager`` gets injected into the class through the constructor, it's easy to pass a mock object within a test:: + // tests/AppBundle/Salary/SalaryCalculatorTest.php + namespace Tests\AppBundle\Salary; + use AppBundle\Salary\SalaryCalculator; + use AppBundle\Entity\Employee; + use Doctrine\ORM\EntityRepository; + use Doctrine\Common\Persistence\ObjectManager; class SalaryCalculatorTest extends \PHPUnit_Framework_TestCase { public function testCalculateTotalSalary() { // First, mock the object to be used in the test - $employee = $this->getMock('\AppBundle\Entity\Employee'); + $employee = $this->getMock(Employee::class); $employee->expects($this->once()) ->method('getSalary') ->will($this->returnValue(1000)); @@ -76,7 +83,7 @@ it's easy to pass a mock object within a test:: // Now, mock the repository so it returns the mock of the employee $employeeRepository = $this - ->getMockBuilder('\Doctrine\ORM\EntityRepository') + ->getMockBuilder(EntityRepository::class) ->disableOriginalConstructor() ->getMock(); $employeeRepository->expects($this->once()) @@ -85,7 +92,7 @@ it's easy to pass a mock object within a test:: // Last, mock the EntityManager to return the mock of the repository $entityManager = $this - ->getMockBuilder('\Doctrine\Common\Persistence\ObjectManager') + ->getMockBuilder(ObjectManager::class) ->disableOriginalConstructor() ->getMock(); $entityManager->expects($this->once()) diff --git a/cookbook/testing/doctrine.rst b/cookbook/testing/doctrine.rst index c263d18c91c..aadbe729113 100644 --- a/cookbook/testing/doctrine.rst +++ b/cookbook/testing/doctrine.rst @@ -20,12 +20,12 @@ If you need to actually execute a query, you will need to boot the kernel to get a valid connection. In this case, you'll extend the ``KernelTestCase``, which makes all of this quite easy:: - // src/AppBundle/Tests/Entity/ProductRepositoryFunctionalTest.php - namespace AppBundle\Tests\Entity; + // tests/AppBundle/Entity/ProductRepositoryTest.php + namespace Tests\AppBundle\Entity; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; - class ProductRepositoryFunctionalTest extends KernelTestCase + class ProductRepositoryTest extends KernelTestCase { /** * @var \Doctrine\ORM\EntityManager @@ -38,10 +38,10 @@ which makes all of this quite easy:: public function setUp() { self::bootKernel(); + $this->em = static::$kernel->getContainer() ->get('doctrine') - ->getManager() - ; + ->getManager(); } public function testSearchByCategoryName() @@ -60,6 +60,7 @@ which makes all of this quite easy:: protected function tearDown() { parent::tearDown(); + $this->em->close(); } } diff --git a/cookbook/testing/profiling.rst b/cookbook/testing/profiling.rst index 1789c69dbc9..d809c4febe2 100644 --- a/cookbook/testing/profiling.rst +++ b/cookbook/testing/profiling.rst @@ -15,9 +15,9 @@ spent in the framework, etc. But before writing assertions, enable the profiler and check that the profiler is indeed available (it is enabled by default in the ``test`` environment):: - class HelloControllerTest extends WebTestCase + class LuckyControllerTest extends WebTestCase { - public function testIndex() + public function testNumberAction() { $client = static::createClient(); @@ -25,7 +25,7 @@ the ``test`` environment):: // (it does nothing if the profiler is not available) $client->enableProfiler(); - $crawler = $client->request('GET', '/hello/Fabien'); + $crawler = $client->request('GET', '/lucky/number'); // ... write some assertions about the Response diff --git a/cookbook/testing/simulating_authentication.rst b/cookbook/testing/simulating_authentication.rst index f2e04acd612..8777a67e2a1 100644 --- a/cookbook/testing/simulating_authentication.rst +++ b/cookbook/testing/simulating_authentication.rst @@ -15,8 +15,8 @@ Another way would be to create a token yourself and store it in a session. While doing this, you have to make sure that an appropriate cookie is sent with a request. The following example demonstrates this technique:: - // src/AppBundle/Tests/Controller/DefaultControllerTest.php - namespace Appbundle\Tests\Controller; + // tests/AppBundle/Controller/DefaultControllerTest.php + namespace Tests\Appbundle\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\BrowserKit\Cookie; diff --git a/cookbook/web_server/built_in.rst b/cookbook/web_server/built_in.rst index dc42eda9cb9..10dceab5b4e 100644 --- a/cookbook/web_server/built_in.rst +++ b/cookbook/web_server/built_in.rst @@ -27,7 +27,7 @@ executing the ``server:start`` command: .. code-block:: bash - $ php app/console server:start + $ php bin/console server:start This starts the web server at ``localhost:8000`` in the background that serves your Symfony application. @@ -37,7 +37,7 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:start 192.168.0.1:8080 + $ php bin/console server:start 192.168.0.1:8080 .. note:: @@ -46,7 +46,7 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:start --force + $ php bin/console server:start --force .. versionadded:: 2.8 The ``--force`` option was introduced in Symfony 2.8. @@ -58,9 +58,9 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:status + $ php bin/console server:status - $ php app/console server:status 192.168.0.1:8080 + $ php bin/console server:status 192.168.0.1:8080 The first command shows if your Symfony application will be server through ``localhost:8000``, the second one does the same for ``192.168.0.1:8080``. @@ -82,7 +82,7 @@ can change the socket passing an IP address and a port as a command-line argumen .. code-block:: bash - $ php app/console server:start 0.0.0.0:8000 + $ php bin/console server:start 0.0.0.0:8000 .. caution:: @@ -101,14 +101,14 @@ script: .. code-block:: bash - $ php app/console server:start --env=test --router=app/config/router_test.php + $ php bin/console server:start --env=test --router=app/config/router_test.php If your application's document root differs from the standard directory layout, you have to pass the correct location using the ``--docroot`` option: .. code-block:: bash - $ php app/console server:start --docroot=public_html + $ php bin/console server:start --docroot=public_html Stopping the Server ------------------- @@ -118,7 +118,7 @@ command: .. code-block:: bash - $ php app/console server:stop + $ php bin/console server:stop Like with the start command, if you omit the socket information, Symfony will stop the web server bound to ``localhost:8000``. Just pass the socket information @@ -126,7 +126,7 @@ when the web server listens to another IP address or to another port: .. code-block:: bash - $ php app/console server:stop 192.168.0.1:8080 + $ php bin/console server:stop 192.168.0.1:8080 .. _`built-in web server`: http://www.php.net/manual/en/features.commandline.webserver.php .. _`php.net`: http://php.net/manual/en/features.commandline.webserver.php#example-411 diff --git a/cookbook/workflow/new_project_svn.rst b/cookbook/workflow/new_project_svn.rst index 8fe7e9eacd9..7cec932445d 100644 --- a/cookbook/workflow/new_project_svn.rst +++ b/cookbook/workflow/new_project_svn.rst @@ -75,17 +75,17 @@ with these steps: .. code-block:: bash $ cd myproject/ - $ svn add --depth=empty app app/cache app/logs app/config web + $ svn add --depth=empty app var/cache var/logs app/config web $ svn propset svn:ignore "vendor" . - $ svn propset svn:ignore "bootstrap*" app/ + $ svn propset svn:ignore "bootstrap*" var/ $ svn propset svn:ignore "parameters.yml" app/config/ - $ svn propset svn:ignore "*" app/cache/ - $ svn propset svn:ignore "*" app/logs/ + $ svn propset svn:ignore "*" var/cache/ + $ svn propset svn:ignore "*" var/logs/ $ svn propset svn:ignore "bundles" web - $ svn ci -m "commit basic Symfony ignore list (vendor, app/bootstrap*, app/config/parameters.yml, app/cache/*, app/logs/*, web/bundles)" + $ svn ci -m "commit basic Symfony ignore list (vendor, var/bootstrap*, app/config/parameters.yml, var/cache/*, var/logs/*, web/bundles)" #. The rest of the files can now be added and committed to the project: