This repository has been archived by the owner on Jan 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
# ConsoleBundle | ||
|
||
Interact with Symfony's container through the command line. Uses [Psysh][psysh] | ||
Interact with Symfony's container through the command line. Uses [Psysh](http://psysh.org/) | ||
for the console. | ||
|
||
## Installation | ||
|
||
composer require --dev mlo/console-bundle | ||
|
||
If you aren't using Symfony Flex, you will need to register the bundle in | ||
`app/AppKernel.php` in the `dev` and/or `test` environment. | ||
`AppKernel.php` in the `dev` and/or `test` environment. | ||
|
||
``` | ||
```php | ||
if (in_array($this->getEnvironment(), array('dev', 'test'))) { | ||
$bundles[] = new Mlo\ConsoleBundle\MloConsoleBundle(); | ||
} | ||
``` | ||
|
||
If you are using Symfony 4 or lower, require the [v1](https://github.com/mloberg/ConsoleBundle/tree/v1) | ||
version of this package. | ||
|
||
composer require --dev mlo/console-bundle:^1.0 | ||
|
||
## Usage | ||
|
||
bin/console console | ||
# OR | ||
bin/console tinker | ||
|
||
This will drop you in a Psysh shell with the variables `$container`, `$kernel` | ||
and `$this` which is mapped to the container. | ||
and `$this`, which references the container. | ||
|
||
## Adding Variables | ||
|
||
If you have a service or parameter you access a lot, you can add them as a | ||
variable in the shell. In your `config_dev.yml` file add these lines: | ||
You can add custom variables to the shell scope with the following config: | ||
|
||
```yaml | ||
mlo_console: | ||
variables: | ||
debug: %kernel.debug% | ||
debug: "%kernel.debug%" | ||
em: "@doctrine.orm.entity_manager" | ||
``` | ||
Now you will have a `$debug` variable with the value of the _kernel.debug_ | ||
parameter and `$em` with your entity manager. | ||
|
||
[psysh]: http://psysh.org/ |