Skip to content

Commit 605097f

Browse files
Adding another page to the console section with info on general usage
1 parent 57d9c48 commit 605097f

File tree

5 files changed

+148
-2
lines changed

5 files changed

+148
-2
lines changed

components/console/index.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Config
2+
======
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
7+
introduction
8+
usage
File renamed without changes.

components/console/usage.rst

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
.. index::
2+
single: Console; Usage
3+
4+
Console Usage
5+
=============
6+
7+
As well as the options you specify for the commands you add there are some
8+
built options as well as a couple of built in commands for the console component.
9+
10+
.. note::
11+
These examples assume you have added a file ``app/console`` to run at
12+
the cli::
13+
14+
#!/usr/bin/env php
15+
# app/console
16+
<?php
17+
18+
use Symfony\Component\Console\Application;
19+
20+
$application = new Application();
21+
// ...
22+
$application->run();
23+
24+
Built in Commands
25+
~~~~~~~~~~~~~~~~~
26+
27+
There is a built in command ``list`` which outputs all the standard options
28+
and the registered commands:
29+
30+
.. code-block:: bash
31+
32+
$ php app/console list
33+
34+
You can get the same output by not running any command as well
35+
36+
.. code-block:: bash
37+
38+
$ php app/console
39+
40+
The help command lists the help information for the specified command. For
41+
example, to get the help for the ``list`` command:
42+
43+
.. code-block:: bash
44+
45+
$ php app/console help list
46+
47+
Global Options
48+
~~~~~~~~~~~~~~
49+
50+
You can get help information for any command with the ``--help`` option, to
51+
get help for the list command:
52+
53+
.. code-block:: bash
54+
55+
$ php app/console list --help
56+
$ php app/console list -h
57+
58+
You can suppress output with:
59+
60+
.. code-block:: bash
61+
62+
$ php app/console list --quiet
63+
$ php app/console list -q
64+
65+
You can get more verbose messages (where this is supported for a command)
66+
with:
67+
68+
.. code-block:: bash
69+
70+
$ php app/console list -verbose
71+
$ php app/console list -v
72+
73+
If you set the optional arguments to give your application a name and version::
74+
75+
$application = new Application('Acme Console Application', '1.2');
76+
77+
then you can use:
78+
79+
.. code-block:: bash
80+
81+
$ php app/console list -version
82+
$ php app/console list -V
83+
84+
to get this information output:
85+
86+
.. code-block:: text
87+
88+
Acme Console Application version 1.2
89+
90+
If you do not provide both arguments then it will just output:
91+
92+
.. code-block:: text
93+
94+
console tool
95+
96+
You can force turning on ANSI output coloring with:
97+
98+
.. code-block:: bash
99+
100+
$ php app/console list -ansi
101+
102+
or turn it off with:
103+
104+
.. code-block:: bash
105+
106+
$ php app/console list -no-ansi
107+
108+
You can suppress any interactive questions from the command you are running with:
109+
110+
.. code-block:: bash
111+
112+
$ php app/console list --no-interaction
113+
$ php app/console list -n
114+
115+
Shortcut Syntax
116+
~~~~~~~~~~~~~~~
117+
118+
You do not have to type out the full command names. You can just type the
119+
shortest unambiguous name to run a command. So if there are non clashing
120+
commands, then you can run ``help`` like this:
121+
122+
.. code-block:: bash
123+
124+
$ php app/console h
125+
126+
If you have commands using ``:`` to namespace commands then you just have
127+
to type the shortest unambiguous text for each part. If you have created the
128+
``demo:greet`` as shown in :doc:`/components/console/introduction` then you
129+
can run it with:
130+
131+
.. code-block:: bash
132+
133+
$ php app/console d:g Fabien
134+
135+
If you choose too short a command so it is ambiguous then no command will be run and
136+
some suggestions of the possible commands to choose from will be output.

components/map.rst.inc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
* :doc:`/components/config/caching`
1010
* :doc:`/components/config/definition`
1111

12-
* **The Console Component**
12+
* :doc:`/components/console/index`
1313

14-
* :doc:`/components/console`
14+
* :doc:`/components/console/introduction`
15+
* :doc:`/components/console/usage`
1516

1617
* **The CSS Selector Component**
1718

redirection_map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
/components/dependency_injection /components/dependency_injection/introduction
1616
/components/event_dispatcher /components/event_dispatcher/introduction
1717
/components/http_foundation /components/http_foundation/introduction
18+
/components/dependency_injection /components/console/introduction

0 commit comments

Comments
 (0)