PHP code example of webman-tech / laravel-console

1. Go to this page and download the library: Download webman-tech/laravel-console library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webman-tech / laravel-console example snippets


use WebmanTech\LaravelConsole\Facades\Artisan;

// 调用命令
Artisan::call('mail:send', [
    'userId' => 123
]);

return [
    // 自定义命令扫描路径
    'commands_path' => [
        app_path() . '/MyCommands' => 'app\MyCommands',
    ],
    
    // 直接注册命令类
    'commands' => [
        \App\Commands\MyCommand::class,
    ],
];

namespace app\command;
 
use Illuminate\Console\Command;
 
class SendEmails extends Command
{
    protected $signature = 'mail:send {userId}';
 
    protected $description = 'Send a marketing email to a user';
 
    public function handle(): void
    {
        // 处理逻辑
    }
}

use WebmanTech\LaravelConsole\Facades\Artisan;

Artisan::call('mail:send', ['userId' => 1]);
bash
php artisan mail:send 1