Download the PHP package rodrigodiez/symfony-rich-console without Composer
On this page you can find all versions of the php package rodrigodiez/symfony-rich-console. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rodrigodiez/symfony-rich-console
More information about rodrigodiez/symfony-rich-console
Files in rodrigodiez/symfony-rich-console
Package symfony-rich-console
Short Description Integrates both Dependency Injection and Event Dispatcher components into non framework Symfony Console applications
License MIT
Informations about the package symfony-rich-console
Symfony rich console
This component integrates both Symfony Dependency Injection and Symfony Event Dispatcher components into Symfony Console applications.
Note: This is only intended if dealing with Symfony Console standalone applications, not web framework ones.
Example:
Installation
1. Download it using composer
Add rodrigodiez/symfony-rich-console
to your composer.json
Now, tell composer to download the component by typing
2. Create a console
You need a entry point file to instantiate and run your application. You can create it at app/console
.
Note that you must extend the custom Application class provided within this component.
The Application class constructor receives two optional parameters:
- configPath: String containing the config path. The application will try to find here the required
parameters.yml
file and other configuration files. Defaults toapp/config
. - configFilenames: Array of file names located in
$configPath
which you want to be loaded into the container. Ej:array('services.yml')
. You typically will define your commands, services, listeners, subscribers, etc in these files.
2. Create a parameters.yml
file
This file is mandatory, it must be located in your configPath
and it must contain, at least, the following info:
3. Done!
Now you can execute your app by typing...
... but the result may be disappointing. This is because we didn't yet registered any commands into the application.
Adding a configuration file
To be able to define your services (commands are defined as services too) it is necessary to create a configuration file in configPath
and tell the application to load it:
Registering commands
Simply register your command as a service and tag it as console.command
.
If your command class implements Symfony\\Component\\DependencyInjection\\ContainerAwareInterface
then container will be injected and you can retrieve it through its $container
property.
Registering listeners and subscribers
That is all!
I hope this to be useful to somebody. Comments, issue reports and pull requests will be appreciated :)
All versions of symfony-rich-console with dependencies
symfony/console Version >=2.3
symfony/dependency-injection Version >=2.3
symfony/finder Version >=2.3
symfony/yaml Version >=2.3
symfony/config Version >=2.3
symfony/event-dispatcher Version >=2.3