diff --git a/_build/_theme/_exts/symfonycom/sphinx/lexer.py b/_build/_theme/_exts/symfonycom/sphinx/lexer.py new file mode 100644 index 00000000000..4100b66d283 --- /dev/null +++ b/_build/_theme/_exts/symfonycom/sphinx/lexer.py @@ -0,0 +1,23 @@ +from pygments.lexer import RegexLexer, bygroups, using +from pygments.token import * +from pygments.lexers.shell import BashLexer, BatchLexer + +class TerminalLexer(RegexLexer): + name = 'Terminal' + aliases = ['terminal'] + filenames = [] + + tokens = { + 'root': [ + ('^\$', Generic.Prompt, 'bash-prompt'), + ('^[^\n>]+>', Generic.Prompt, 'dos-prompt'), + ('^#.+$', Comment.Single), + ('^.+$', Generic.Output), + ], + 'bash-prompt': [ + ('(.+)$', bygroups(using(BashLexer)), '#pop') + ], + 'dos-prompt': [ + ('(.+)$', bygroups(using(BatchLexer)), '#pop') + ], + } diff --git a/_build/conf.py b/_build/conf.py index 177c744c2df..44303b18dbe 100644 --- a/_build/conf.py +++ b/_build/conf.py @@ -24,6 +24,7 @@ from pygments.lexers.special import TextLexer from pygments.lexers.text import RstLexer from pygments.lexers.web import PhpLexer +from symfonycom.sphinx.lexer import TerminalLexer # -- General configuration ----------------------------------------------------- @@ -108,6 +109,7 @@ lexers['rst'] = RstLexer() lexers['varnish3'] = CLexer() lexers['varnish4'] = CLexer() +lexers['terminal'] = TerminalLexer() config_block = { 'markdown': 'Markdown', diff --git a/assetic/asset_management.rst b/assetic/asset_management.rst index ff31093380f..4380b9fd884 100644 --- a/assetic/asset_management.rst +++ b/assetic/asset_management.rst @@ -596,7 +596,7 @@ environment is just too slow. Instead, each time you use your application in the ``prod`` environment (and therefore, each time you deploy), you should run the following command: -.. code-block:: bash +.. code-block:: terminal $ php app/console assetic:dump --env=prod --no-debug @@ -648,7 +648,7 @@ the following change in your ``config_dev.yml`` file: Next, since Symfony is no longer generating these assets for you, you'll need to dump them manually. To do so, run the following command: -.. code-block:: bash +.. code-block:: terminal $ php app/console assetic:dump @@ -657,7 +657,7 @@ environment. The big disadvantage is that you need to run this each time you update an asset. Fortunately, by using the ``assetic:watch`` command, assets will be regenerated automatically *as they change*: -.. code-block:: bash +.. code-block:: terminal $ php app/console assetic:watch diff --git a/assetic/php.rst b/assetic/php.rst index 68afb9788bd..5ab5888ae9c 100644 --- a/assetic/php.rst +++ b/assetic/php.rst @@ -30,7 +30,7 @@ associated libraries. Therefore, before enabling the filters used in this articl you must install two libraries. Open a command console, browse to your project directory and execute the following commands: -.. code-block:: bash +.. code-block:: terminal $ composer require leafo/scssphp $ composer require patchwork/jsqueeze diff --git a/assetic/uglifyjs.rst b/assetic/uglifyjs.rst index b2ec9c5eb58..47cc886fe2d 100644 --- a/assetic/uglifyjs.rst +++ b/assetic/uglifyjs.rst @@ -28,13 +28,13 @@ The global installation method makes all your projects use the very same UglifyJ version, which simplifies its maintenance. Open your command console and execute the following command (you may need to run it as a root user): -.. code-block:: bash +.. code-block:: terminal $ npm install -g uglify-js Now you can execute the global ``uglifyjs`` command anywhere on your system: -.. code-block:: bash +.. code-block:: terminal $ uglifyjs --help @@ -45,7 +45,7 @@ It's also possible to install UglifyJS inside your project only, which is useful when your project requires a specific UglifyJS version. To do this, install it without the ``-g`` option and specify the path where to put the module: -.. code-block:: bash +.. code-block:: terminal $ cd /path/to/your/symfony/project $ npm install uglify-js --prefix app/Resources @@ -57,7 +57,7 @@ an npm `package.json`_ file and specify your dependencies there. Now you can execute the ``uglifyjs`` command that lives in the ``node_modules`` directory: -.. code-block:: bash +.. code-block:: terminal $ "./app/Resources/node_modules/.bin/uglifyjs" --help @@ -115,7 +115,7 @@ your JavaScripts: The path where UglifyJS is installed may vary depending on your system. To find out where npm stores the ``bin`` folder, execute the following command: - .. code-block:: bash + .. code-block:: terminal $ npm bin -g @@ -251,7 +251,7 @@ Install, Configure and Use UglifyCSS The usage of UglifyCSS works the same way as UglifyJS. First, make sure the node package is installed: -.. code-block:: bash +.. code-block:: terminal # global installation $ npm install -g uglifycss diff --git a/best_practices/business-logic.rst b/best_practices/business-logic.rst index b05ec44df1b..2ad86cfea2f 100644 --- a/best_practices/business-logic.rst +++ b/best_practices/business-logic.rst @@ -279,7 +279,7 @@ Data Fixtures As fixtures support is not enabled by default in Symfony, you should execute the following command to install the Doctrine fixtures bundle: -.. code-block:: bash +.. code-block:: terminal $ composer require "doctrine/doctrine-fixtures-bundle" @@ -316,7 +316,7 @@ Assuming you have at least one fixtures class and that the database access is configured properly, you can load your fixtures by executing the following command: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:fixtures:load diff --git a/best_practices/creating-the-project.rst b/best_practices/creating-the-project.rst index c70df8db7bd..bca43c13161 100644 --- a/best_practices/creating-the-project.rst +++ b/best_practices/creating-the-project.rst @@ -25,7 +25,7 @@ Now that everything is correctly set up, you can create a new project based on Symfony. In your command console, browse to a directory where you have permission to create files and execute the following commands: -.. code-block:: bash +.. code-block:: terminal # Linux, Mac OS X $ cd projects/ @@ -145,7 +145,7 @@ that follows these best practices: If your Symfony installation doesn't come with a pre-generated AppBundle, you can generate it by hand executing this command: - .. code-block:: bash + .. code-block:: terminal $ php app/console generate:bundle --namespace=AppBundle --dir=src --format=annotation --no-interaction diff --git a/best_practices/introduction.rst b/best_practices/introduction.rst index 2c5661c6671..7a2a2ec7c17 100644 --- a/best_practices/introduction.rst +++ b/best_practices/introduction.rst @@ -74,7 +74,7 @@ best practices in mind. This project, called the Symfony Demo application, can be obtained through the Symfony Installer. First, `download and install`_ the installer and then execute this command to download the demo application: -.. code-block:: bash +.. code-block:: terminal # Linux and Mac OS X $ symfony demo diff --git a/best_practices/templates.rst b/best_practices/templates.rst index 75c37044a19..da09b535d43 100644 --- a/best_practices/templates.rst +++ b/best_practices/templates.rst @@ -69,7 +69,7 @@ the Markdown contents of each post into HTML. To do this, first, install the excellent `Parsedown`_ Markdown parser as a new dependency of the project: -.. code-block:: bash +.. code-block:: terminal $ composer require erusev/parsedown diff --git a/bundles.rst b/bundles.rst index f1494768b43..a0c6f40d75c 100644 --- a/bundles.rst +++ b/bundles.rst @@ -119,7 +119,7 @@ And while it doesn't do anything yet, AcmeTestBundle is now ready to be used. And as easy as this is, Symfony also provides a command-line interface for generating a basic bundle skeleton: -.. code-block:: bash +.. code-block:: terminal $ php app/console generate:bundle --namespace=Acme/TestBundle diff --git a/bundles/best_practices.rst b/bundles/best_practices.rst index 6d0b7aff034..44e65e1d66c 100644 --- a/bundles/best_practices.rst +++ b/bundles/best_practices.rst @@ -207,7 +207,7 @@ following standardized instructions in your ``README.md`` file. Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle: - ```bash + ```console $ composer require "~1" ``` @@ -254,7 +254,7 @@ following standardized instructions in your ``README.md`` file. Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle: - .. code-block:: bash + .. code-block:: terminal $ composer require "~1" diff --git a/bundles/installation.rst b/bundles/installation.rst index 80dfafc008e..3b8f4cef20b 100644 --- a/bundles/installation.rst +++ b/bundles/installation.rst @@ -34,7 +34,7 @@ the bundle on the `Packagist.org`_ site. Now that you know the package name, you can install it via Composer: -.. code-block:: bash +.. code-block:: terminal $ composer require friendsofsymfony/user-bundle @@ -42,7 +42,7 @@ This will choose the best version for your project, add it to ``composer.json`` and download its code into the ``vendor/`` directory. If you need a specific version, include it as the second argument of the `composer require`_ command: -.. code-block:: bash +.. code-block:: terminal $ composer require friendsofsymfony/user-bundle "~2.0" @@ -106,14 +106,14 @@ in ``app/config/config.yml``. The bundle's documentation will tell you about the configuration, but you can also get a reference of the bundle's configuration via the ``config:dump-reference`` command: -.. code-block:: bash +.. code-block:: terminal $ app/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 +.. code-block:: terminal $ app/console config:dump-reference assetic diff --git a/bundles/prepend_extension.rst b/bundles/prepend_extension.rst index f4a0aff3cc9..b0d1b0e4f08 100644 --- a/bundles/prepend_extension.rst +++ b/bundles/prepend_extension.rst @@ -131,3 +131,10 @@ The above would be the equivalent of writing the following into the // ... 'use_acme_goodbye' => false, )); + +More than one Bundle using PrependExtensionInterface +---------------------------------------------------- + +If there is more than one bundle that prepends the same extension and defines +the same key, the bundle that is registered **first** will take priority: +next bundles won't override this specific config setting. diff --git a/components/console/changing_default_command.rst b/components/console/changing_default_command.rst index adbf31a4ae3..994da675b17 100644 --- a/components/console/changing_default_command.rst +++ b/components/console/changing_default_command.rst @@ -43,7 +43,7 @@ Executing the application and changing the default Command:: Test the new default console command by running the following: -.. code-block:: bash +.. code-block:: terminal $ php application.php diff --git a/components/console/logger.rst b/components/console/logger.rst index d5fda564540..207e7172daa 100644 --- a/components/console/logger.rst +++ b/components/console/logger.rst @@ -98,8 +98,8 @@ constructor:: // ... $formatLevelMap = array( - LogLevel::CRITICAL => ConsoleLogger::INFO, - LogLevel::DEBUG => ConsoleLogger::ERROR, + LogLevel::CRITICAL => ConsoleLogger::ERROR, + LogLevel::DEBUG => ConsoleLogger::INFO, ); $logger = new ConsoleLogger($output, array(), $formatLevelMap); diff --git a/components/console/usage.rst b/components/console/usage.rst index 67ac232c1ac..4b2bb147940 100644 --- a/components/console/usage.rst +++ b/components/console/usage.rst @@ -28,26 +28,26 @@ Built-in Commands There is a built-in command ``list`` which outputs all the standard options and the registered commands: -.. code-block:: bash +.. code-block:: terminal $ php application.php list You can get the same output by not running any command as well -.. code-block:: bash +.. code-block:: terminal $ php application.php The help command lists the help information for the specified command. For example, to get the help for the ``list`` command: -.. code-block:: bash +.. code-block:: terminal $ php application.php help list Running ``help`` without specifying a command will list the global options: -.. code-block:: bash +.. code-block:: terminal $ php application.php help @@ -57,14 +57,14 @@ Global Options You can get help information for any command with the ``--help`` option. To get help for the list command: -.. code-block:: bash +.. code-block:: terminal $ php application.php list --help $ php application.php list -h You can suppress output with: -.. code-block:: bash +.. code-block:: terminal $ php application.php list --quiet $ php application.php list -q @@ -72,14 +72,14 @@ You can suppress output with: You can get more verbose messages (if this is supported for a command) with: -.. code-block:: bash +.. code-block:: terminal $ php application.php list --verbose $ php application.php list -v To output even more verbose messages you can use these options: -.. code-block:: bash +.. code-block:: terminal $ php application.php list -vv $ php application.php list -vvv @@ -90,7 +90,7 @@ If you set the optional arguments to give your application a name and version:: then you can use: -.. code-block:: bash +.. code-block:: terminal $ php application.php list --version $ php application.php list -V @@ -109,19 +109,19 @@ If you do not provide both arguments then it will just output: You can force turning on ANSI output coloring with: -.. code-block:: bash +.. code-block:: terminal $ php application.php list --ansi or turn it off with: -.. code-block:: bash +.. code-block:: terminal $ php application.php list --no-ansi You can suppress any interactive questions from the command you are running with: -.. code-block:: bash +.. code-block:: terminal $ php application.php list --no-interaction $ php application.php list -n @@ -133,7 +133,7 @@ You do not have to type out the full command names. You can just type the shortest unambiguous name to run a command. So if there are non-clashing commands, then you can run ``help`` like this: -.. code-block:: bash +.. code-block:: terminal $ php application.php h @@ -142,7 +142,7 @@ to type the shortest unambiguous text for each part. If you have created the ``demo:greet`` as shown in :doc:`/components/console` then you can run it with: -.. code-block:: bash +.. code-block:: terminal $ php application.php d:g Fabien diff --git a/components/form.rst b/components/form.rst index 8e58433864e..a1d7b5e3932 100644 --- a/components/form.rst +++ b/components/form.rst @@ -115,7 +115,7 @@ Protection against CSRF attacks is built into the Form component, but you need to explicitly enable it or replace it with a custom solution. If you want to use the built-in support, first install the Security CSRF component: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/security-csrf @@ -166,7 +166,7 @@ component offers a rich integration. To use the integration, you'll need the twig bridge, which provides integration between Twig and several Symfony components: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/twig-bridge @@ -244,7 +244,7 @@ To use the built-in integration, be sure that your project has Symfony's Translation and :doc:`Config ` components installed: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/translation symfony/config @@ -289,7 +289,7 @@ array or object) and pass it through your own validation system. To use the integration with Symfony's Validator component, first make sure it's installed in your application: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/validator diff --git a/components/using_components.rst b/components/using_components.rst index 3cb2eab270d..dccdb144654 100644 --- a/components/using_components.rst +++ b/components/using_components.rst @@ -22,7 +22,7 @@ Using the Finder Component **2.** Open a terminal and use Composer to grab the library. -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/finder @@ -62,7 +62,7 @@ Using all of the Components If you want to use all of the Symfony Components, then instead of adding them one by one, you can include the ``symfony/symfony`` package: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/symfony diff --git a/configuration.rst b/configuration.rst index 4c58ace6779..7e4291849c8 100644 --- a/configuration.rst +++ b/configuration.rst @@ -117,7 +117,7 @@ There are *two* ways to know *what* keys you can configure: For example, if you want to configure something in Twig, you can see an example dump of all available configuration options by running: -.. code-block:: bash +.. code-block:: terminal $ php app/console config:dump twig diff --git a/configuration/apache_router.rst b/configuration/apache_router.rst index a8b4f8a7c33..f7cbf7bb70f 100644 --- a/configuration/apache_router.rst +++ b/configuration/apache_router.rst @@ -96,7 +96,7 @@ To test that it's working, create a very basic route for the AppBundle: Now generate the mod_rewrite rules: -.. code-block:: bash +.. code-block:: terminal $ php app/console router:dump-apache -e=prod --no-debug diff --git a/configuration/environments.rst b/configuration/environments.rst index a66424fa000..02dbf9a24d6 100644 --- a/configuration/environments.rst +++ b/configuration/environments.rst @@ -224,7 +224,7 @@ By default, Symfony commands are executed in the ``dev`` environment and with th debug mode enabled. Use the ``--env`` and ``--no-debug`` options to modify this behavior: -.. code-block:: bash +.. code-block:: terminal # 'dev' environment and debug enabled $ php app/console command_name diff --git a/configuration/external_parameters.rst b/configuration/external_parameters.rst index 06e3f3fa370..2455040f150 100644 --- a/configuration/external_parameters.rst +++ b/configuration/external_parameters.rst @@ -50,7 +50,7 @@ the following ``VirtualHost`` configuration: you must export these as shell variables. On a Unix system, you can run the following: - .. code-block:: bash + .. code-block:: terminal $ export SYMFONY__DATABASE__USER=user $ export SYMFONY__DATABASE__PASSWORD=secret diff --git a/configuration/override_dir_structure.rst b/configuration/override_dir_structure.rst index 6bcdcd46dd4..4189d3214bd 100644 --- a/configuration/override_dir_structure.rst +++ b/configuration/override_dir_structure.rst @@ -161,7 +161,7 @@ file: Now you just need to clear the cache and dump the assets again and your application should work: - .. code-block:: bash + .. code-block:: terminal $ php app/console cache:clear --env=prod $ php app/console assetic:dump --env=prod --no-debug diff --git a/console.rst b/console.rst index cada5d73bba..2bd81154728 100644 --- a/console.rst +++ b/console.rst @@ -66,7 +66,7 @@ Executing the Command After configuring the command, you can execute it in the terminal: -.. code-block:: bash +.. code-block:: terminal $ php app/console app:create-users @@ -95,7 +95,7 @@ messages to the console):: Now, try executing the command: -.. code-block:: bash +.. code-block:: terminal $ php app/console app:create-user User Creator @@ -136,7 +136,7 @@ Use input options or arguments to pass information to the command:: Now, you can pass the username to the command: -.. code-block:: bash +.. code-block:: terminal $ php app/console app:create-user Wouter User Creator diff --git a/console/command_in_controller.rst b/console/command_in_controller.rst index 4323beb8e4a..ee610478606 100644 --- a/console/command_in_controller.rst +++ b/console/command_in_controller.rst @@ -66,7 +66,7 @@ can be used to convert this to colorful HTML. First, require the package: -.. code-block:: bash +.. code-block:: terminal $ composer require sensiolabs/ansi-to-html diff --git a/console/input.rst b/console/input.rst index 82a147b86d9..bc3c64270bd 100644 --- a/console/input.rst +++ b/console/input.rst @@ -52,7 +52,7 @@ You now have access to a ``last_name`` argument in your command:: The command can now be used in either of the following ways: -.. code-block:: bash +.. code-block:: terminal $ php app/console app:greet Fabien Hi Fabien! @@ -73,7 +73,7 @@ to greet all your friends). Only the last argument can be a list:: To use this, just specify as many names as you want: -.. code-block:: bash +.. code-block:: terminal $ php app/console app:greet Fabien Ryan Bernhard @@ -137,7 +137,7 @@ Next, use this in the command to print the message multiple times:: Now, when you run the task, you can optionally specify a ``--iterations`` flag: -.. code-block:: bash +.. code-block:: terminal # no --iterations provided, the default (1) is used $ php app/console app:greet Fabien diff --git a/console/usage.rst b/console/usage.rst index 0e2c1e5befd..ca2ed6f9237 100644 --- a/console/usage.rst +++ b/console/usage.rst @@ -15,13 +15,13 @@ will be different depending on the environment. For example, the ``cache:clear`` command will clear and warm the cache for the specified environment only. To clear and warm the ``prod`` cache you need to run: -.. code-block:: bash +.. code-block:: terminal $ php app/console cache:clear --env=prod or the equivalent: -.. code-block:: bash +.. code-block:: terminal $ php app/console cache:clear -e prod @@ -29,6 +29,6 @@ In addition to changing the environment, you can also choose to disable debug mo This can be useful where you want to run commands in the ``dev`` environment but avoid the performance hit of collecting debug data: -.. code-block:: bash +.. code-block:: terminal $ php app/console list --no-debug diff --git a/contributing/code/git.rst b/contributing/code/git.rst index 5dbe97bae01..ce0642c5599 100644 --- a/contributing/code/git.rst +++ b/contributing/code/git.rst @@ -37,6 +37,6 @@ your ``.git/config`` file: After a fetch, getting the GitHub discussion for a commit is then a matter of adding ``--show-notes=github-comments`` to the ``git show`` command: -.. code-block:: bash +.. code-block:: terminal $ git show HEAD --show-notes=github-comments diff --git a/contributing/code/patches.rst b/contributing/code/patches.rst index 90781ed5193..2d2677584af 100644 --- a/contributing/code/patches.rst +++ b/contributing/code/patches.rst @@ -27,7 +27,7 @@ Configure Git Set up your user information with your real name and a working email address: -.. code-block:: bash +.. code-block:: terminal $ git config --global user.name "Your Name" $ git config --global user.email you@example.com @@ -53,14 +53,14 @@ Set up your user information with your real name and a working email address: repository. If you have already installed Git, you can check the value of this setting by typing: - .. code-block:: bash + .. code-block:: terminal $ git config core.autocrlf This will return either "false", "input" or "true"; "true" and "false" being the wrong values. Change it to "input" by typing: - .. code-block:: bash + .. code-block:: terminal $ git config --global core.autocrlf input @@ -79,13 +79,13 @@ Get the Symfony source code: * After the "forking action" has completed, clone your fork locally (this will create a ``symfony`` directory): -.. code-block:: bash +.. code-block:: terminal $ git clone git@github.com:USERNAME/symfony.git * Add the upstream repository as a remote: -.. code-block:: bash +.. code-block:: terminal $ cd symfony $ git remote add upstream git://github.com/symfony/symfony.git @@ -132,20 +132,20 @@ Create a Topic Branch Each time you want to work on a patch for a bug or on an enhancement, create a topic branch: -.. code-block:: bash +.. code-block:: terminal $ git checkout -b BRANCH_NAME master Or, if you want to provide a bugfix for the ``2.7`` branch, first track the remote ``2.7`` branch locally: -.. code-block:: bash +.. code-block:: terminal $ git checkout -t origin/2.7 Then create a new branch off the ``2.7`` branch to work on the bugfix: -.. code-block:: bash +.. code-block:: terminal $ git checkout -b BRANCH_NAME 2.7 @@ -225,7 +225,7 @@ Rebase your Patch Before submitting your patch, update your branch (needed if it takes you a while to finish your changes): -.. code-block:: bash +.. code-block:: terminal $ git checkout master $ git fetch upstream @@ -242,14 +242,14 @@ When doing the ``rebase`` command, you might have to fix merge conflicts. ``git status`` will show you the *unmerged* files. Resolve all the conflicts, then continue the rebase: -.. code-block:: bash +.. code-block:: terminal $ git add ... # add resolved files $ git rebase --continue Check that all tests still pass and push your branch remotely: -.. code-block:: bash +.. code-block:: terminal $ git push --force origin BRANCH_NAME @@ -336,7 +336,7 @@ Based on the feedback on the pull request, you might need to rework your patch. Before re-submitting the patch, rebase with ``upstream/master`` or ``upstream/2.7``, don't merge; and force the push to the origin: -.. code-block:: bash +.. code-block:: terminal $ git rebase -f upstream/master $ git push --force origin BRANCH_NAME diff --git a/contributing/code/tests.rst b/contributing/code/tests.rst index 6256cd6f416..4e9416686a9 100644 --- a/contributing/code/tests.rst +++ b/contributing/code/tests.rst @@ -20,7 +20,7 @@ To run the Symfony test suite, install the external dependencies used during the tests, such as Doctrine, Twig and Monolog. To do so, :doc:`install Composer ` and execute the following: -.. code-block:: bash +.. code-block:: terminal $ composer update @@ -32,7 +32,7 @@ Running the Tests Then, run the test suite from the Symfony root directory with the following command: -.. code-block:: bash +.. code-block:: terminal $ php ./phpunit symfony @@ -45,7 +45,7 @@ what's going on and if the tests are broken because of the new code. want to test a single component, type its path after the ``phpunit`` command, e.g.: - .. code-block:: bash + .. code-block:: terminal $ php ./phpunit src/Symfony/Component/Finder/ diff --git a/contributing/documentation/overview.rst b/contributing/documentation/overview.rst index be264b0e2fd..c766849f5ad 100644 --- a/contributing/documentation/overview.rst +++ b/contributing/documentation/overview.rst @@ -87,7 +87,7 @@ contribute to Symfony. uses the ``projects/symfony-docs/`` directory to store the documentation; change this value accordingly): -.. code-block:: bash +.. code-block:: terminal $ cd projects/ $ git clone git://github.com//symfony-docs.git @@ -95,7 +95,7 @@ this value accordingly): **Step 3.** Add the original Symfony docs repository as a "Git remote" executing this command: -.. code-block:: bash +.. code-block:: terminal $ cd symfony-docs/ $ git remote add upstream https://github.com/symfony/symfony-docs.git @@ -103,7 +103,7 @@ this command: If things went right, you'll see the following when listing the "remotes" of your project: -.. code-block:: bash +.. code-block:: terminal $ git remote -v origin git@github.com:/symfony-docs.git (fetch) @@ -113,7 +113,7 @@ your project: Fetch all the commits of the upstream branches by executing this command: -.. code-block:: bash +.. code-block:: terminal $ git fetch upstream @@ -124,7 +124,7 @@ Symfony repository and on your own fork. You'll see this in action in a moment. memorable name for the new branch (if you are fixing a reported issue, use ``fix_XXX`` as the branch name, where ``XXX`` is the number of the issue): -.. code-block:: bash +.. code-block:: terminal $ git checkout -b improve_install_chapter upstream/2.7 @@ -141,7 +141,7 @@ new feature, switch to the first Symfony version that included it, e.g. even remove any content and do your best to comply with the :doc:`/contributing/documentation/standards`. Then commit your changes! -.. code-block:: bash +.. code-block:: terminal # if the modified content existed before $ git add setup.rst @@ -149,7 +149,7 @@ even remove any content and do your best to comply with the **Step 6.** **Push** the changes to your forked repository: -.. code-block:: bash +.. code-block:: terminal $ git push origin improve_install_chapter @@ -189,7 +189,7 @@ In case you are asked to add or modify something, don't create a new pull request. Instead, make sure that you are on the correct branch, make your changes and push the new changes: -.. code-block:: bash +.. code-block:: terminal $ cd projects/symfony-docs/ $ git checkout improve_install_chapter @@ -214,7 +214,7 @@ your contributions will be much easier to complete. Here is a **checklist** of steps that will guide you through your next contribution to the Symfony docs: -.. code-block:: bash +.. code-block:: terminal # create a new branch based on the oldest maintained version $ cd projects/symfony-docs/ @@ -269,13 +269,13 @@ purposes following these steps: #. Install `Sphinx`_ and `Sphinx Extensions for PHP and Symfony`_ (depending on your system, you may need to execute this command as root user): - .. code-block:: bash + .. code-block:: terminal $ pip install sphinx~=1.3.0 git+https://github.com/fabpot/sphinx-php.git #. Run the following command to build the documentation in HTML format: - .. code-block:: bash + .. code-block:: terminal # Linux and macOS $ ./_build/make html diff --git a/controller.rst b/controller.rst index 47bf078dc4e..3f43f5e39ae 100644 --- a/controller.rst +++ b/controller.rst @@ -252,7 +252,7 @@ need:: What other services exist? To list all services, use the ``debug:container`` console command: -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:container diff --git a/create_framework/dependency_injection.rst b/create_framework/dependency_injection.rst index d380e19abd3..e8ef15f0353 100644 --- a/create_framework/dependency_injection.rst +++ b/create_framework/dependency_injection.rst @@ -85,7 +85,7 @@ front controller? As you might expect, there is a solution. We can solve all these issues and some more by using the Symfony dependency injection container: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/dependency-injection diff --git a/create_framework/event_dispatcher.rst b/create_framework/event_dispatcher.rst index 3964cf5ae46..a75231be9e3 100644 --- a/create_framework/event_dispatcher.rst +++ b/create_framework/event_dispatcher.rst @@ -17,7 +17,7 @@ pattern, the *Mediator*, to allow any kind of behaviors to be attached to our framework; the Symfony EventDispatcher Component implements a lightweight version of this pattern: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/event-dispatcher diff --git a/create_framework/front_controller.rst b/create_framework/front_controller.rst index af2f75b572d..b5d2bd5e360 100644 --- a/create_framework/front_controller.rst +++ b/create_framework/front_controller.rst @@ -156,7 +156,7 @@ other files won't be accessible from the client anymore. To test your changes in a browser (``http://localhost:4321/hello/?name=Fabien``), run the PHP built-in server: -.. code-block:: bash +.. code-block:: terminal $ php -S 127.0.0.1:4321 -t web/ web/front.php diff --git a/create_framework/http_foundation.rst b/create_framework/http_foundation.rst index f8cc458d10f..34130941e80 100644 --- a/create_framework/http_foundation.rst +++ b/create_framework/http_foundation.rst @@ -112,7 +112,7 @@ layer. To use this component, add it as a dependency of the project: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/http-foundation diff --git a/create_framework/http_kernel_controller_resolver.rst b/create_framework/http_kernel_controller_resolver.rst index 463cf40d2e8..9957b9089ce 100644 --- a/create_framework/http_kernel_controller_resolver.rst +++ b/create_framework/http_kernel_controller_resolver.rst @@ -39,7 +39,7 @@ instantiated. To solve this issue, and a bunch more, let's install and use the HttpKernel component: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/http-kernel diff --git a/create_framework/introduction.rst b/create_framework/introduction.rst index d747f32e214..03ab5169729 100644 --- a/create_framework/introduction.rst +++ b/create_framework/introduction.rst @@ -84,7 +84,7 @@ classes, how you will reference external dependencies, etc. To store your new framework, create a directory somewhere on your machine: -.. code-block:: bash +.. code-block:: terminal $ mkdir framework $ cd framework @@ -111,7 +111,7 @@ start with the simplest web application we can think of in PHP:: If you have PHP 5.4, you can use the PHP built-in server to test this great application in a browser (``http://localhost:4321/index.php?name=Fabien``): -.. code-block:: bash +.. code-block:: terminal $ php -S 127.0.0.1:4321 diff --git a/create_framework/routing.rst b/create_framework/routing.rst index 7a2b75c6fd2..d866db098a4 100644 --- a/create_framework/routing.rst +++ b/create_framework/routing.rst @@ -45,7 +45,7 @@ want to support dynamic paths to allow embedding data directly into the URL To support this feature, add the Symfony Routing component as a dependency: -.. code-block:: bash +.. code-block:: terminal $ composer require symfony/routing diff --git a/create_framework/unit_testing.rst b/create_framework/unit_testing.rst index 3a852745141..b40aac46361 100644 --- a/create_framework/unit_testing.rst +++ b/create_framework/unit_testing.rst @@ -113,7 +113,7 @@ are testing that our framework converts this exception to a 404 response. Executing this test is as simple as running ``phpunit`` from the ``example.com`` directory: -.. code-block:: bash +.. code-block:: terminal $ phpunit @@ -178,7 +178,7 @@ the one we have set in the controller. To check that we have covered all possible use cases, run the PHPUnit test coverage feature (you need to enable `XDebug`_ first): -.. code-block:: bash +.. code-block:: terminal $ phpunit --coverage-html=cov/ @@ -188,7 +188,7 @@ been visited when the tests were executed). Alternatively you can output the result directly to the console: -.. code-block:: bash +.. code-block:: terminal $ phpunit --coverage-text diff --git a/deployment.rst b/deployment.rst index 079c1c9160f..e20e06c7d44 100644 --- a/deployment.rst +++ b/deployment.rst @@ -116,7 +116,7 @@ A) Check Requirements Check if your server meets the requirements by running: -.. code-block:: bash +.. code-block:: terminal $ php app/check.php @@ -134,7 +134,7 @@ update the ``vendor/`` directory, then transfer that with your source code) or afterwards on the server. Either way, just update your vendors as you normally do: -.. code-block:: bash +.. code-block:: terminal $ composer install --no-dev --optimize-autoloader @@ -155,7 +155,7 @@ D) Clear your Symfony Cache Make sure you clear (and warm-up) your Symfony cache: -.. code-block:: bash +.. code-block:: terminal $ php app/console cache:clear --env=prod --no-debug @@ -164,7 +164,7 @@ E) Dump your Assetic Assets If you're using Assetic, you'll also want to dump your assets: -.. code-block:: bash +.. code-block:: terminal $ php app/console assetic:dump --env=prod --no-debug diff --git a/deployment/azure-website.rst b/deployment/azure-website.rst index 43c2e302f69..254cbe39109 100644 --- a/deployment/azure-website.rst +++ b/deployment/azure-website.rst @@ -193,7 +193,7 @@ In the console prompt, type the following three commands to copy the original ``php_intl.dll`` extension file into a custom website ``ext/`` directory. This new directory must be created under the main directory ``site/wwwroot``. -.. code-block:: bash +.. code-block:: terminal $ cd site\wwwroot $ mkdir ext @@ -233,7 +233,7 @@ Deploying from Git First, make sure Git is correctly installed on your local machine using the following command in your terminal: -.. code-block:: bash +.. code-block:: terminal $ git --version @@ -281,7 +281,7 @@ Website. Now, from the command line on your local machine, type the following at the root of your Symfony project: -.. code-block:: bash +.. code-block:: terminal $ git remote add azure https://@.scm.azurewebsites.net:443/.git $ git push azure master @@ -312,7 +312,7 @@ step is to configure the application and install the third party dependencies it requires that aren't tracked by Git. Switch back to the online **Console** of the Kudu application and execute the following commands in it: -.. code-block:: bash +.. code-block:: terminal $ cd site\wwwroot $ curl -sS https://getcomposer.org/installer | php @@ -386,7 +386,7 @@ command line interface if you're using Doctrine. In the online **Console** tool of the Kudu application, run the following command to mount the tables into your MySQL database. -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:schema:update --force @@ -397,7 +397,7 @@ may have additional commands to execute for setup (see :doc:`/deployment`). Make sure that your application is running by browsing the ``app.php`` front controller with your web browser and the following URL: -.. code-block:: bash +.. code-block:: terminal http://.azurewebsites.net/web/app.php diff --git a/deployment/fortrabbit.rst b/deployment/fortrabbit.rst index 98051bb6eff..32768583c69 100644 --- a/deployment/fortrabbit.rst +++ b/deployment/fortrabbit.rst @@ -203,7 +203,7 @@ file (optional) in the project root. Add fortrabbit as a (additional) Git remote and add your configuration changes: -.. code-block:: bash +.. code-block:: terminal $ git remote add fortrabbit git@deploy.eu2.frbit.com:.git $ git add composer.json composer.lock @@ -211,7 +211,7 @@ Add fortrabbit as a (additional) Git remote and add your configuration changes: Commit and push -.. code-block:: bash +.. code-block:: terminal $ git commit -m 'fortrabbit config' $ git push fortrabbit master -u @@ -220,7 +220,7 @@ Commit and push Replace ```` with the name of your fortrabbit App. -.. code-block:: bash +.. code-block:: terminal Commit received, starting build of branch master diff --git a/deployment/heroku.rst b/deployment/heroku.rst index 8386d49e4ec..5438208f4fa 100644 --- a/deployment/heroku.rst +++ b/deployment/heroku.rst @@ -56,7 +56,7 @@ Creating a new Application on Heroku To create a new Heroku application that you can push to, use the CLI ``create`` command: -.. code-block:: bash +.. code-block:: terminal $ heroku create @@ -119,7 +119,7 @@ directory of the application and add just the following content: If you prefer working on the command console, execute the following commands to create the ``Procfile`` file and to add it to the repository: -.. code-block:: bash +.. code-block:: terminal $ echo "web: bin/heroku-php-apache2 web/" > Procfile $ git add . @@ -147,7 +147,7 @@ environment variable named ``SYMFONY_ENV`` and use that environment if nothing else is explicitly set. As Heroku exposes all `config vars`_ as environment variables, you can issue a single command to prepare your app for a deployment: -.. code-block:: bash +.. code-block:: terminal $ heroku config:set SYMFONY_ENV=prod @@ -178,7 +178,7 @@ In this case, you need to confirm by typing ``yes`` and hitting ```` key Then, deploy your application executing this command: -.. code-block:: bash +.. code-block:: terminal $ git push heroku master @@ -230,7 +230,7 @@ And that's it! If you now open your browser, either by manually pointing it to the URL ``heroku create`` gave you, or by using the Heroku Toolbelt, the application will respond: -.. code-block:: bash +.. code-block:: terminal $ heroku open Opening mighty-hamlet-1981... done @@ -309,7 +309,7 @@ This is also very useful to build assets on the production system, e.g. with Ass to use both buildpacks. To override buildpack auto-detection, you need to explicitly set the buildpack: - .. code-block:: bash + .. code-block:: terminal $ heroku buildpacks:set heroku/nodejs Buildpack set. Next release on your-application will use heroku/nodejs. diff --git a/deployment/platformsh.rst b/deployment/platformsh.rst index 4848e38f3fe..7ba29d2853a 100644 --- a/deployment/platformsh.rst +++ b/deployment/platformsh.rst @@ -140,7 +140,7 @@ Deploy your Application Now you need to add a remote to Platform.sh in your Git repository (copy the command that you see on the Platform.sh web UI): -.. code-block:: bash +.. code-block:: terminal $ git remote add platform [PROJECT-ID]@git.[CLUSTER].platform.sh:[PROJECT-ID].git @@ -151,7 +151,7 @@ command that you see on the Platform.sh web UI): Commit the Platform.sh specific files created in the previous section: -.. code-block:: bash +.. code-block:: terminal $ git add .platform.app.yaml .platform/* $ git add app/config/config.yml app/config/parameters_platform.php @@ -159,7 +159,7 @@ Commit the Platform.sh specific files created in the previous section: Push your code base to the newly added remote: -.. code-block:: bash +.. code-block:: terminal $ git push platform master diff --git a/doctrine.rst b/doctrine.rst index fbd87c757d2..21b435cd25e 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -114,7 +114,7 @@ information. By convention, this information is usually configured in an Now that Doctrine can connect to your database, the following command can automatically generate an empty ``test_project`` database for you: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:database:create @@ -126,7 +126,7 @@ can automatically generate an empty ``test_project`` database for you: They might even remember to do it the very first time, but forget that it's all gone after running a relatively common command during development: - .. code-block:: bash + .. code-block:: terminal $ php app/console doctrine:database:drop --force $ php app/console doctrine:database:create @@ -225,7 +225,7 @@ just a simple PHP class. simple entity classes for you. This will ask you interactive questions to help you build any entity: - .. code-block:: bash + .. code-block:: terminal $ php app/console doctrine:generate:entity @@ -394,7 +394,7 @@ getter and setter methods (e.g. ``getName()``, ``setName($name)``) in order to access its properties in the rest of your application's code. Fortunately, the following command can generate these boilerplate methods automatically: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:generate:entities AppBundle/Entity/Product @@ -434,7 +434,7 @@ doesn't replace your existing methods). You can also generate all known entities (i.e. any PHP class with Doctrine mapping information) of a bundle or an entire namespace: -.. code-block:: bash +.. code-block:: terminal # generates all entities in the AppBundle $ php app/console doctrine:generate:entities AppBundle @@ -453,7 +453,7 @@ corresponding ``product`` table in your database. Fortunately, Doctrine can automatically create all the database tables needed for every known entity in your application. To do this, run: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:schema:update --force diff --git a/doctrine/associations.rst b/doctrine/associations.rst index 51d7a245285..b25425ed48f 100644 --- a/doctrine/associations.rst +++ b/doctrine/associations.rst @@ -12,7 +12,7 @@ Start by creating the ``Category`` entity. Since you know that you'll eventually need to persist category objects through Doctrine, you can let Doctrine create the class for you. -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:generate:entity --no-interaction \ --entity="AppBundle:Category" \ @@ -179,7 +179,7 @@ own a collection of its related ``Product`` objects. .. seealso:: To understand ``inversedBy`` and ``mappedBy`` usage, see Doctrine's - `Association Updates` documentation. + `Association Updates`_ documentation. .. tip:: @@ -191,7 +191,7 @@ own a collection of its related ``Product`` objects. Now that you've added new properties to both the ``Product`` and ``Category`` classes, tell Doctrine to generate the missing getter and setter methods for you: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:generate:entities AppBundle @@ -222,7 +222,7 @@ property to figure out how the relationship is mapped. Before you continue, be sure to tell Doctrine to add the new ``category`` table, the new ``product.category_id`` column, and the new foreign key: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:schema:update --force diff --git a/doctrine/console.rst b/doctrine/console.rst index 09eade986e3..7a126e44a6a 100644 --- a/doctrine/console.rst +++ b/doctrine/console.rst @@ -9,7 +9,7 @@ The Doctrine2 ORM integration offers several console commands under the ``doctrine`` namespace. To view the command list you can use the ``list`` command: -.. code-block:: bash +.. code-block:: terminal $ php app/console list doctrine @@ -18,7 +18,7 @@ about any of these commands (or any Symfony command) by running the ``help`` command. For example, to get details about the ``doctrine:database:create`` task, run: -.. code-block:: bash +.. code-block:: terminal $ php app/console help doctrine:database:create @@ -28,7 +28,7 @@ Some notable or interesting tasks include: environment is configured efficiently for production. This should always be run in the ``prod`` environment: - .. code-block:: bash + .. code-block:: terminal $ php app/console doctrine:ensure-production-settings --env=prod diff --git a/doctrine/multiple_entity_managers.rst b/doctrine/multiple_entity_managers.rst index e6d0ec53472..5f73f8701e9 100644 --- a/doctrine/multiple_entity_managers.rst +++ b/doctrine/multiple_entity_managers.rst @@ -162,7 +162,7 @@ for each entity manager. When working with multiple connections to create your databases: -.. code-block:: bash +.. code-block:: terminal # Play only with "default" connection $ php app/console doctrine:database:create @@ -172,7 +172,7 @@ When working with multiple connections to create your databases: When working with multiple entity managers to update your schema: -.. code-block:: bash +.. code-block:: terminal # Play only with "default" mappings $ php app/console doctrine:schema:update --force diff --git a/doctrine/registration_form.rst b/doctrine/registration_form.rst index 0d14fc13d65..0fb651220f7 100644 --- a/doctrine/registration_form.rst +++ b/doctrine/registration_form.rst @@ -376,7 +376,7 @@ Update your Database Schema If you've updated the ``User`` entity during this tutorial, you have to update your database schema using this command: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:schema:update --force diff --git a/doctrine/repository.rst b/doctrine/repository.rst index 32e0bcf94bf..573850960ef 100644 --- a/doctrine/repository.rst +++ b/doctrine/repository.rst @@ -57,7 +57,7 @@ Doctrine can generate empty repository classes for all the entities in your application via the same command used earlier to generate the missing getter and setter methods: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:generate:entities AppBundle diff --git a/doctrine/reverse_engineering.rst b/doctrine/reverse_engineering.rst index 9cf9eb51d85..5ead848a89b 100644 --- a/doctrine/reverse_engineering.rst +++ b/doctrine/reverse_engineering.rst @@ -57,7 +57,7 @@ is to ask Doctrine to introspect the database and generate the corresponding metadata files. Metadata files describe the entity class to generate based on table fields. -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:mapping:import --force AcmeBlogBundle xml @@ -90,7 +90,7 @@ The generated ``BlogPost.orm.xml`` metadata file looks as follows: Once the metadata files are generated, you can ask Doctrine to build related entity classes by executing the following two commands. -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:mapping:convert annotation ./src $ php app/console doctrine:generate:entities AcmeBlogBundle diff --git a/email/spool.rst b/email/spool.rst index 923c2b8afe0..4ede9ebbfcc 100644 --- a/email/spool.rst +++ b/email/spool.rst @@ -122,19 +122,19 @@ Now, when your app sends an email, it will not actually be sent but instead added to the spool. Sending the messages from the spool is done separately. There is a console command to send the messages in the spool: -.. code-block:: bash +.. code-block:: terminal $ php app/console swiftmailer:spool:send --env=prod It has an option to limit the number of messages to be sent: -.. code-block:: bash +.. code-block:: terminal $ php app/console swiftmailer:spool:send --message-limit=10 --env=prod You can also set the time limit in seconds: -.. code-block:: bash +.. code-block:: terminal $ php app/console swiftmailer:spool:send --time-limit=10 --env=prod diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 6250fe77872..0cb808244df 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -268,14 +268,14 @@ Debugging Event Listeners You can find out what listeners are registered in the event dispatcher using the console. To show all events and their listeners, run: -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:event-dispatcher You can get registered listeners for a particular event by specifying its name: -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:event-dispatcher kernel.exception diff --git a/form/events.rst b/form/events.rst index 1a621cff6f0..d2b6e325520 100644 --- a/form/events.rst +++ b/form/events.rst @@ -228,8 +228,7 @@ View data Normalized data transformed using a view transformer information about the forms. The ``Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener`` subscribes to the ``FormEvents::POST_SUBMIT`` event in order to - automatically validate the denormalized object and to update the normalized - representation as well as the view representations. + automatically validate the denormalized object. Registering Event Listeners or Event Subscribers ------------------------------------------------ diff --git a/frontend/bower.rst b/frontend/bower.rst index 7a27ba73d44..2c82d4f84ab 100644 --- a/frontend/bower.rst +++ b/frontend/bower.rst @@ -15,7 +15,7 @@ Installing Bower Bower_ is built on top of `Node.js`_. Make sure you have that installed and then run: -.. code-block:: bash +.. code-block:: terminal $ npm install -g bower @@ -63,7 +63,7 @@ To create a ``bower.json`` file, just run ``bower init``. Now you're ready to start adding things to your project. For example, to add Bootstrap_ to your ``bower.json`` and download it, just run: -.. code-block:: bash +.. code-block:: terminal $ bower install --save bootstrap @@ -123,7 +123,7 @@ Currently, you should probably *commit* the assets downloaded by Bower instead of adding the directory (e.g. ``web/assets/vendor``) to your ``.gitignore`` file: -.. code-block:: bash +.. code-block:: terminal $ git add web/assets/vendor diff --git a/introduction/from_flat_php_to_symfony2.rst b/introduction/from_flat_php_to_symfony2.rst index c509d89d326..45521ca6088 100644 --- a/introduction/from_flat_php_to_symfony2.rst +++ b/introduction/from_flat_php_to_symfony2.rst @@ -441,7 +441,7 @@ content: Next, `download Composer`_ and then run the following command, which will download Symfony into a ``vendor/`` directory: -.. code-block:: bash +.. code-block:: terminal $ composer install diff --git a/introduction/symfony1.rst b/introduction/symfony1.rst index 41481ed9009..c124884e036 100644 --- a/introduction/symfony1.rst +++ b/introduction/symfony1.rst @@ -92,7 +92,7 @@ directory. This allows you to keep assets organized inside your bundle, but still make them available to the public. To make sure that all bundles are available, run the following command: -.. code-block:: bash +.. code-block:: terminal $ php app/console assets:install web @@ -187,14 +187,14 @@ Using the Console In symfony1, the console is in the root directory of your project and is called ``symfony``: -.. code-block:: bash +.. code-block:: terminal $ php symfony In Symfony2, the console is now in the app sub-directory and is called ``console``: -.. code-block:: bash +.. code-block:: terminal $ php app/console diff --git a/page_creation.rst b/page_creation.rst index f810d717197..5d681ef4339 100644 --- a/page_creation.rst +++ b/page_creation.rst @@ -134,7 +134,7 @@ variable so we can render that:: } } -Finally, template files should live in the ``app/Resources/view`` directory. Create +Finally, template files should live in the ``app/Resources/views`` directory. Create a new ``app/Resources/views/lucky`` directory with a new ``number.html.twig`` file inside: diff --git a/performance.rst b/performance.rst index f6cffd5e219..67bd1989652 100644 --- a/performance.rst +++ b/performance.rst @@ -59,7 +59,7 @@ The simplest solution is to tell Composer to build a "class map" (i.e. a big array of the locations of all the classes). This can be done from the command line, and might become part of your deploy process: -.. code-block:: bash +.. code-block:: terminal $ composer dump-autoload --optimize diff --git a/profiler/profiling_data.rst b/profiler/profiling_data.rst index 80b02a366e8..f4fab3f0216 100644 --- a/profiler/profiling_data.rst +++ b/profiler/profiling_data.rst @@ -50,7 +50,7 @@ Lastly, if you want to manipulate profiling data on a different machine than the one where the information was generated, use the ``profiler:export`` and ``profiler:import`` commands: -.. code-block:: bash +.. code-block:: terminal # on the production machine $ php app/console profiler:export > profile.data diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst index 9498959533d..c7b08a5c1d7 100644 --- a/quick_tour/the_architecture.rst +++ b/quick_tour/the_architecture.rst @@ -270,7 +270,7 @@ up, it is your responsibility to clear the cache when you update your code or change its configuration. Execute this command to clear the cache in the ``prod`` environment: -.. code-block:: bash +.. code-block:: terminal $ php app/console cache:clear --env=prod @@ -287,13 +287,13 @@ your productivity by automating tedious and repetitive tasks. Run it without any arguments to learn more about its capabilities: -.. code-block:: bash +.. code-block:: terminal $ php app/console The ``--help`` option helps you discover the usage of a command: -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:router --help diff --git a/reference/events.rst b/reference/events.rst index b415282d8db..119f83a4f0f 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -151,7 +151,7 @@ Listener Class Name =================================================================================== ======== :class:`Symfony\\Component\\HttpKernel\\EventListener\\EsiListener` 0 :class:`Symfony\\Component\\HttpKernel\\EventListener\\ResponseListener` 0 -:class:`Symfony\\Bundle\\SecurityBundle\\EventListener\\ResponseListener` 0 +:class:`Symfony\\Component\\Security\\Http\\RememberMe\\ResponseListener` 0 :class:`Symfony\\Component\\HttpKernel\\EventListener\\ProfilerListener` -100 :class:`Symfony\\Bundle\\FrameworkBundle\\EventListener\\TestSessionListener` -128 :class:`Symfony\\Bundle\\WebProfilerBundle\\EventListener\\WebDebugToolbarListener` -128 diff --git a/reference/forms/types/options/by_reference.rst.inc b/reference/forms/types/options/by_reference.rst.inc index e2552817470..c4839b74ab0 100644 --- a/reference/forms/types/options/by_reference.rst.inc +++ b/reference/forms/types/options/by_reference.rst.inc @@ -3,9 +3,9 @@ by_reference **type**: ``boolean`` **default**: ``true`` -In most cases, if you have a ``name`` field, then you expect ``setName()`` -to be called on the underlying object. In some cases, however, ``setName()`` -may *not* be called. Setting ``by_reference`` ensures that the setter is +In most cases, if you have an ``author`` field, then you expect ``setAuthor()`` +to be called on the underlying object. In some cases, however, ``setAuthor()`` +may *not* be called. Setting ``by_reference`` to ``false`` ensures that the setter is called in all cases. To explain this further, here's a simple example:: diff --git a/reference/requirements.rst b/reference/requirements.rst index 5bce19c6ba1..099b5ebe2c8 100644 --- a/reference/requirements.rst +++ b/reference/requirements.rst @@ -12,7 +12,7 @@ can easily see if your system passes all requirements by running the a different ``php.ini`` configuration file, it's also a good idea to check your requirements from the command line via: -.. code-block:: bash +.. code-block:: terminal $ php app/check.php diff --git a/routing.rst b/routing.rst index b6440dacc5d..9262b78b9d4 100644 --- a/routing.rst +++ b/routing.rst @@ -591,10 +591,6 @@ sees our annotation routes: For more details on loading routes, including how to prefix the paths of loaded routes, see :doc:`/routing/external_resources`. -The path will *not*, however, match simply ``/blog``. That's because, -by default, all placeholders are required. This can be changed by adding -a placeholder value to the ``defaults`` array. - .. index:: single: Routing; Generating URLs diff --git a/routing/debug.rst b/routing/debug.rst index 7ed31b7d968..5c5c251765a 100644 --- a/routing/debug.rst +++ b/routing/debug.rst @@ -9,7 +9,7 @@ and get detailed information about your routes. A great way to see every route in your application is via the ``debug:router`` console command. Execute the command by running the following from the root of your project. -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:router @@ -28,14 +28,14 @@ your application: You can also get very specific information on a single route by including the route name after the command: -.. code-block:: bash +.. code-block:: terminal $ php app/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 +.. code-block:: terminal $ php app/console router:match /blog/my-latest-post diff --git a/security.rst b/security.rst index a9adbdb5ce7..fc543a76b43 100644 --- a/security.rst +++ b/security.rst @@ -512,7 +512,7 @@ else, you'll want to encode their passwords. The best algorithm to use is Of course, your users' passwords now need to be encoded with this exact algorithm. For hardcoded users, since 2.7 you can use the built-in command: -.. code-block:: bash +.. code-block:: terminal $ php app/console security:encode-password @@ -1087,6 +1087,14 @@ key: Logging Out ----------- +.. caution:: + + Notice that when using http-basic authenticated firewalls, there is no + real way to log out : the only way to *log out* is to have the browser + stop sending your name and password on every request. Clearing your + browser cache or restarting your browser usually helps. Some web developer + tools might be helpful here too. + Usually, you'll also want your users to be able to log out. Fortunately, the firewall can handle this automatically for you when you activate the ``logout`` config parameter: @@ -1187,14 +1195,6 @@ is defined by the ``target`` parameter above (e.g. the ``homepage``). :class:`Symfony\\Component\\Security\\Http\\Logout\\LogoutSuccessHandlerInterface`. See :doc:`Security Configuration Reference `. -.. caution:: - - Notice that when using http-basic authenticated firewalls, there is no - real way to log out : the only way to *log out* is to have the browser - stop sending your name and password on every request. Clearing your - browser cache or restarting your browser usually helps. Some web developer - tools might be helpful here too. - .. _security-role-hierarchy: Hierarchical Roles diff --git a/security/_ircmaxwell_password-compat.rst.inc b/security/_ircmaxwell_password-compat.rst.inc index b8f0f1d021d..4b09fcfe7ca 100644 --- a/security/_ircmaxwell_password-compat.rst.inc +++ b/security/_ircmaxwell_password-compat.rst.inc @@ -3,6 +3,6 @@ If you're using PHP 5.4 or lower, you'll need to install the ``ircmaxell/password-compat`` library via Composer in order to be able to use the ``bcrypt`` encoder: - .. code-block:: bash + .. code-block:: terminal $ composer require ircmaxell/password-compat "~1.0" diff --git a/security/acl.rst b/security/acl.rst index 41cedf4ffe5..29eaa5acab7 100644 --- a/security/acl.rst +++ b/security/acl.rst @@ -94,7 +94,7 @@ First, you need to configure the connection the ACL system is supposed to use: After the connection is configured, you have to import the database structure. Fortunately, there is a task for this. Simply run the following command: -.. code-block:: bash +.. code-block:: terminal $ php app/console init:acl diff --git a/security/entity_provider.rst b/security/entity_provider.rst index 1ae093c7617..3942e5e08c3 100644 --- a/security/entity_provider.rst +++ b/security/entity_provider.rst @@ -143,13 +143,13 @@ To make things shorter, some of the getter and setter methods aren't shown. But you can :ref:`generate ` these by running: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:generate:entities AppBundle/Entity/User Next, make sure to :ref:`create the database table `: -.. code-block:: bash +.. code-block:: terminal $ php app/console doctrine:schema:update --force @@ -305,7 +305,7 @@ for details. Below is an export of the ``app_users`` table from MySQL with user ``admin`` and password ``admin`` (which has been encoded). -.. code-block:: bash +.. code-block:: terminal $ mysql> SELECT * FROM app_users; +----+----------+--------------------------------------------------------------+--------------------+-----------+ @@ -540,10 +540,10 @@ above). This gives us a "fresh" User object. But Symfony also uses the ``username``, ``salt``, and ``password`` to verify that the User has not changed between requests (it also calls your ``AdvancedUserInterface`` methods if you implement it). Failing to serialize these may cause you to -be logged out on each request. If your User implements the +be logged out on each request. If your user implements the :class:`Symfony\\Component\\Security\\Core\\User\\EquatableInterface`, -then instead of these properties being checked, your ``isEqualTo`` method -is simply called, and you can check whatever properties you want. Unless +then instead of these properties being checked, your :method:`Symfony\\Component\\Security\\Core\\User\\EquatableInterface::isEqualTo` method +is called, and you can check whatever properties you want. Unless you understand this, you probably *won't* need to implement this interface or worry about it. diff --git a/security/form_login_setup.rst b/security/form_login_setup.rst index e933694867a..c47ba6f07f1 100644 --- a/security/form_login_setup.rst +++ b/security/form_login_setup.rst @@ -70,8 +70,7 @@ First, enable form login under your firewall: Now, when the security system initiates the authentication process, it will redirect the user to the login form ``/login``. Implementing this login form -visually is your job. First, create a new ``SecurityController`` inside a -bundle:: +is your job. First, create a new ``SecurityController`` inside a bundle:: // src/AppBundle/Controller/SecurityController.php namespace AppBundle\Controller; @@ -139,8 +138,7 @@ configuration (``login``): return $collection; -Great! Next, add the logic to ``loginAction`` that will display the login -form:: +Great! Next, add the logic to ``loginAction`` that displays the login form:: // src/AppBundle/Controller/SecurityController.php @@ -154,14 +152,10 @@ form:: // last username entered by the user $lastUsername = $authenticationUtils->getLastUsername(); - return $this->render( - 'security/login.html.twig', - array( - // last username entered by the user - 'last_username' => $lastUsername, - 'error' => $error, - ) - ); + return $this->render('security/login.html.twig', array( + 'last_username' => $lastUsername, + 'error' => $error, + )); } Don't let this controller confuse you. As you'll see in a moment, when the @@ -181,7 +175,7 @@ Finally, create the template: .. code-block:: html+twig {# app/Resources/views/security/login.html.twig #} - {# ... you will probably extends your base template, like base.html.twig #} + {# ... you will probably extend your base template, like base.html.twig #} {% if error %}
{{ error.messageKey|trans(error.messageData, 'security') }}
@@ -236,13 +230,12 @@ Finally, create the template: It may contain more information - or even sensitive information - about the authentication failure, so use it wisely! -The form can look like anything, but has a few requirements: - -* The form must POST to the ``login`` route, since that's what you configured - under the ``form_login`` key in ``security.yml``. +The form can look like anything, but it usually follows some conventions: -* The username must have the name ``_username`` and the password must have - the name ``_password``. +* The ``
`` element sends a ``POST`` request to the ``login`` route, since + that's what you configured under the ``form_login`` key in ``security.yml``; +* The username field has the name ``_username`` and the password field has the + name ``_password``. .. tip:: @@ -382,64 +375,6 @@ fixes the problem: array('path' => '^/', 'role' => 'ROLE_ADMIN'), ), -Also, if your firewall does *not* allow for anonymous users (no ``anonymous`` -key), you'll need to create a special firewall that allows anonymous users -for the login page: - -.. configuration-block:: - - .. code-block:: yaml - - # app/config/security.yml - - # ... - firewalls: - # order matters! This must be before the ^/ firewall - login_firewall: - pattern: ^/login$ - anonymous: ~ - secured_area: - pattern: ^/ - form_login: ~ - - .. code-block:: xml - - - - - - - - - - - - - - - - - - .. code-block:: php - - // app/config/security.php - - // ... - 'firewalls' => array( - 'login_firewall' => array( - 'pattern' => '^/login$', - 'anonymous' => null, - ), - 'secured_area' => array( - 'pattern' => '^/', - 'form_login' => null, - ), - ), - 3. Be Sure check_path Is Behind a Firewall ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/security/security_checker.rst b/security/security_checker.rst index daafcfdf4cc..8ea447d773d 100644 --- a/security/security_checker.rst +++ b/security/security_checker.rst @@ -9,7 +9,7 @@ contain security vulnerabilities. That's why Symfony includes a command called ``security:check`` that checks your ``composer.lock`` file to find any known security vulnerability in your installed dependencies: -.. code-block:: bash +.. code-block:: terminal $ php app/console security:check @@ -29,7 +29,7 @@ FriendsOfPHP organization. To enable the ``security:check`` command, make sure the `SensioDistributionBundle`_ is installed. - .. code-block:: bash + .. code-block:: terminal $ composer require 'sensio/distribution-bundle' diff --git a/service_container/debug.rst b/service_container/debug.rst index 0cf7124dff6..2110837e83f 100644 --- a/service_container/debug.rst +++ b/service_container/debug.rst @@ -8,13 +8,13 @@ How to Debug the Service Container & List Services You can find out what services are registered with the container using the console. To show all services and the class for each service, run: -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:container By default, only public services are shown, but you can also view private services: -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:container --show-private @@ -28,6 +28,6 @@ By default, only public services are shown, but you can also view private servic You can get more detailed information about a particular service by specifying its id: -.. code-block:: bash +.. code-block:: terminal $ php app/console debug:container app.mailer diff --git a/service_container/lazy_services.rst b/service_container/lazy_services.rst index e11c28492b1..431da97852b 100644 --- a/service_container/lazy_services.rst +++ b/service_container/lazy_services.rst @@ -28,7 +28,7 @@ Installation In order to use the lazy service instantiation, you will first need to install the ``ocramius/proxy-manager`` package: -.. code-block:: bash +.. code-block:: terminal $ composer require ocramius/proxy-manager @@ -37,7 +37,7 @@ the ``ocramius/proxy-manager`` package: If you're not using the full-stack framework, you also have to install the `ProxyManager bridge`_ - .. code-block:: bash + .. code-block:: terminal $ composer require symfony/proxy-manager-bridge:~2.3 diff --git a/service_container/optional_dependencies.rst b/service_container/optional_dependencies.rst index cd9a38e28cd..95fa9d177b3 100644 --- a/service_container/optional_dependencies.rst +++ b/service_container/optional_dependencies.rst @@ -76,7 +76,8 @@ call if the service exists and remove the method call if it does not: services: app.newsletter_manager: class: AppBundle\Newsletter\NewsletterManager - arguments: ['@?app.mailer'] + calls: + - [setMailer, ['@?app.mailer']] .. code-block:: xml @@ -119,10 +120,10 @@ call if the service exists and remove the method call if it does not: )); In YAML, the special ``@?`` syntax tells the service container that the dependency -is optional. Of course, the ``NewsletterManager`` must also be rewritten to -allow for an optional dependency:: +is optional. Of course, the ``NewsletterManager`` must also be rewritten by +adding a ``setMailer()`` method:: - public function __construct(Mailer $mailer = null) + public function setMailer(Mailer $mailer) { // ... } diff --git a/setup.rst b/setup.rst index fff7a20a4ca..c244fc7ffee 100644 --- a/setup.rst +++ b/setup.rst @@ -14,10 +14,14 @@ Symfony provides a dedicated application called the **Symfony Installer** to eas the creation of Symfony applications. This installer is a PHP 5.4 compatible executable that needs to be installed on your system only once: -.. code-block:: bash +.. code-block:: terminal # Linux and macOS systems $ sudo mkdir -p /usr/local/bin + some + output + + stuff $ sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony $ sudo chmod a+x /usr/local/bin/symfony @@ -31,7 +35,7 @@ executable that needs to be installed on your system only once: environment variable to create the global command or move it to any other directory convenient for you: - .. code-block:: bash + .. code-block:: terminal # for example, if WAMP is used ... c:\> move symfony c:\wamp\bin\php @@ -49,7 +53,7 @@ executable that needs to be installed on your system only once: Once the Symfony Installer is installed, create your first Symfony application with the ``new`` command: -.. code-block:: bash +.. code-block:: terminal $ symfony new my_project_name @@ -70,7 +74,7 @@ Basing your Project on a Specific Symfony Version In case your project needs to be based on a specific Symfony version, use the optional second argument of the ``new`` command: -.. code-block:: bash +.. code-block:: terminal # use the most recent version in any Symfony branch $ symfony new my_project_name 2.8 @@ -105,14 +109,14 @@ If you don't have Composer installed in your computer, start by ``create-project`` command to create a new Symfony application based on its latest stable version: -.. code-block:: bash +.. code-block:: terminal $ composer create-project symfony/framework-standard-edition my_project_name You can also install any other Symfony version by passing a second argument to the ``create-project`` command: -.. code-block:: bash +.. code-block:: terminal $ composer create-project symfony/framework-standard-edition my_project_name "2.8.*" @@ -129,7 +133,7 @@ Symfony leverages the internal PHP web server (available since PHP 5.4) to run applications while developing them. Therefore, running a Symfony application is a matter of browsing to the project directory and executing this command: -.. code-block:: bash +.. code-block:: terminal $ cd my_project_name/ $ php app/console server:run @@ -188,7 +192,7 @@ security vulnerabilities. Execute the ``update`` Composer command to update them all at once (this can take up to several minutes to complete depending on the complexity of your project): -.. code-block:: bash +.. code-block:: terminal $ cd my_project_name/ $ composer update @@ -198,7 +202,7 @@ complexity of your project): Symfony provides a command to check whether your project's dependencies contain any known security vulnerability: - .. code-block:: bash + .. code-block:: terminal $ php app/console security:check @@ -243,7 +247,7 @@ It's recommended to not submit some files (:ref:`parameters.yml