|
| 1 | +.. index:: |
| 2 | + single: Console; Usage |
| 3 | + |
| 4 | +How to use the Console |
| 5 | +====================== |
| 6 | + |
| 7 | +The :doc:`/components/console/usage` page of the components documentation looks |
| 8 | +at the global console options. When you use the console as part of the full |
| 9 | +stack framework, some additional global options are available as well. |
| 10 | + |
| 11 | +By default, console commands run in the ``dev`` environment and you may want |
| 12 | +to change this for some commands. For example, you may want to run some commands |
| 13 | +in the ``prod`` environment for performance reasons. Also, the result of some commands |
| 14 | +will be different depending on the environment. for example, the ``cache:clear`` |
| 15 | +command will clear and warm the cache for the specified environment only. To |
| 16 | +clear and warm the ``prod`` cache you need to run: |
| 17 | + |
| 18 | +.. code-block:: bash |
| 19 | +
|
| 20 | + $ php app/console cache:clear --env=prod |
| 21 | +
|
| 22 | +or the equivalent: |
| 23 | + |
| 24 | +.. code-block:: bash |
| 25 | +
|
| 26 | + $ php app/console cache:clear -e=prod |
| 27 | +
|
| 28 | +In addition to changing the environment, you can also choose to disable debug mode. |
| 29 | +This can be useful where you want to run commands in the ``dev`` environment |
| 30 | +but avoid the performance hit of collecting debug data: |
| 31 | + |
| 32 | +.. code-block:: bash |
| 33 | +
|
| 34 | + $ php app/console list --no-debug |
| 35 | +
|
| 36 | +There is an interactive shell which allows you to enter commands without having to |
| 37 | +specify ``php app/console`` each time, which is useful if you need to run several |
| 38 | +commands. To enter the shell run: |
| 39 | + |
| 40 | +.. code-block:: bash |
| 41 | +
|
| 42 | + $ php app/console --shell |
| 43 | + $ php app/console -s |
| 44 | +
|
| 45 | +You can now just run commands with the command name: |
| 46 | + |
| 47 | +.. code-block:: bash |
| 48 | +
|
| 49 | + Symfony > list |
| 50 | +
|
| 51 | +When using the shell you can choose to run each command in a separate process: |
| 52 | + |
| 53 | +.. code-block:: bash |
| 54 | +
|
| 55 | + $ php app/console --shell --process-isolation |
| 56 | + $ php app/console -s --process-isolation |
| 57 | +
|
| 58 | +When you do this, the output will not be colorized and interactivity is not |
| 59 | +supported so you will need to pass all command params explicitly. |
| 60 | + |
| 61 | +.. note:: |
| 62 | + |
| 63 | + Unless you are using isolated processes, clearing the cache in the shell |
| 64 | + will not have an effect on subsequent commands you run. This is because |
| 65 | + the original cached files are still being used. |
0 commit comments