Commands
Commands
Laravel commands in custom packages are not published, for whatever reason.
Commands in your package are simply integrated with load
in the Laravel boot raiser.
You can also use Commands
to keep a clear overview in Bootraiser.
Bootraiser Options
Possible instructions
with method
Raiser::forProvider($this)->Commands();
Raiser::forProvider($this)->loadCommands();
with array
['Commands']
['loadCommands']
via Method
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
Raiser::forProvider($this)->loadCommands();
}
}
via config array
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
// or from your config
Raiser::forProvider($this)->runFromArray(['Commands']);
}
}
Package command example
<?php
namespace YourCompany\YourPackage\Console\Commands;
use Illuminate\Console\Command;
class YourPackageFlightCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'your-package:flight';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
//
echo 'works'.PHP_EOL;
}
}
With an active console, the package commands can be executed directly as usual in Laravel.
php artisan your-package:flight
Structure
- AboutCommand.php
- YourPackageFlightCommand.php
References
Last updated on