|
1 | | -Console Commands |
2 | | -================ |
| 1 | +How to Create Console/Command-Line Commands |
| 2 | +=========================================== |
3 | 3 |
|
4 | | -Symfony2 ships with a console component. The framework offers a simple convention that allows |
5 | | -you to register your own console commands for any recurring task, cronjobs, imports or other batch-jobs. |
| 4 | +Symfony2 ships with a console component. The framework offers a simple convention |
| 5 | +that allows you to register your own console commands for any recurring task, |
| 6 | +cronjobs, imports or other batch-jobs. |
6 | 7 |
|
7 | | -To make the console commands available automatically with Symfony2 you have to create a ``Command`` |
8 | | -directory inside your bundle and create a php file suffixed with ``Command.php`` for each |
9 | | -task that you want to provide. If we want to to extend the HelloBundle to greet us from the commandline |
10 | | -aswell we get this simple block of necessary code: |
| 8 | +To make the console commands available automatically with Symfony2 you have |
| 9 | +to create a ``Command`` directory inside your bundle and create a php file |
| 10 | +suffixed with ``Command.php`` for each task that you want to provide. If |
| 11 | +we want to to extend the HelloBundle to greet us from the command line as |
| 12 | +well we get this simple block of necessary code: |
11 | 13 |
|
12 | 14 | .. code-block: php |
13 | 15 |
|
@@ -56,8 +58,9 @@ Advanced Usage |
56 | 58 | Using the Dependency Injection Container |
57 | 59 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
58 | 60 |
|
59 | | -Using the Symfony\Bundle\FrameworkBundle\Command\Command as base class we also have access to |
60 | | -the dependency injection container. As an example we could easily extend our task to be translatable: |
| 61 | +Using the Symfony\Bundle\FrameworkBundle\Command\Command as base class we |
| 62 | +also have access to the dependency injection container. As an example we |
| 63 | +could easily extend our task to be translatable: |
61 | 64 |
|
62 | 65 | .. code-block: php |
63 | 66 |
|
|
0 commit comments