I have some command line scripts that I would like to modify to use Laravel's features (Eloquent etc).
How do I do that? I am aware that Laravel bootstraps from the index.html file. Is there any provision for running command-line apps / scripts?
php artisan make:command MyCommand
.
- Go to
/app/Console/Commands/MyCommand.php
-
Find:
protected $signature = 'command:name';
-
Change to:
protected $signature = 'my:command';
-
There's handle()
method there you are able to fire some code:
public function handle()
{
echo 'Hello world';
}
-
In the /app/Console/Kernel.php
you will find protected variable $commands
. Add your Command's class name.
protected $commands = [
// ...
Commands\MyCommand::class,
];
-
Run php artisan my:command
.
原文引用自 https://stackoverflow.com/questions/40993513/command-line-scripts-in-laravel
|
|
|
|
|
|
|
|
|
Text-to-speech function is limited to 200 characters
留言列表