|
| 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, 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. 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 so 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 | + $ php app/console cache:clear -e=prod |
| 22 | +
|
| 23 | +As well as changing the environment you can also choose to disable debug mode. |
| 24 | +This can be useful where you want to run commands in the ``dev`` environment |
| 25 | +but avoid the performance hit of collecting debug data: |
| 26 | + |
| 27 | +.. code-block:: bash |
| 28 | +
|
| 29 | + $ php app/console list --no-debug |
| 30 | +
|
| 31 | +There is an interactive shell which allows you to enter commands without having to |
| 32 | +specify ``php app/console`` each time, which is useful if you need to run several |
| 33 | +commands. To enter the shell run: |
| 34 | + |
| 35 | +.. code-block:: bash |
| 36 | +
|
| 37 | + $ php app/console --shell |
| 38 | + $ php app/console -s |
| 39 | +
|
| 40 | +You can now just run commands with the command name: |
| 41 | + |
| 42 | +.. code-block:: bash |
| 43 | +
|
| 44 | + Symfony > list |
| 45 | +
|
| 46 | +When using the shell you can choose to run each command in a separate process: |
| 47 | + |
| 48 | +.. code-block:: bash |
| 49 | +
|
| 50 | + $ php app/console --shell --process-isolation |
| 51 | + $ php app/console -s --process-isolation |
| 52 | +
|
| 53 | +When you do this the output will not be colorized and interactivity is not |
| 54 | +supported so you will need to pass all command params explicitly. |
| 55 | + |
| 56 | +.. note:: |
| 57 | + |
| 58 | + Unless you are using isolated processes, clearing the cache in the shell |
| 59 | + will not have an effect on subsequent commands you run. This is because |
| 60 | + the original cached files will still be being used. |
0 commit comments