You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.4执行php artisan make:job时--queued选项不存在求助

Fixing "The '--queued' option does not exist" in Laravel 5.4

Hey there! Let's get this queued job issue sorted out for you. The problem here is pretty straightforward: Laravel 5.4 doesn't support the --queued option for the make:job command. That flag was added in later Laravel versions (around 5.5), so running that command in 5.4 will throw the error you're seeing.

Here's how you can create a queued job correctly in Laravel 5.4:

  1. Create the job without the --queued flag
    Run this command in your terminal instead:

    php artisan make:job SendSMSMessages
    

    This will generate a new job file at app/Jobs/SendSMSMessages.php.

  2. Ensure the job implements the ShouldQueue interface
    Open the generated SendSMSMessages.php file. By default, Laravel 5.4 might already include this, but double-check to be sure. Your class should look something like this:

    namespace App\Jobs;
    
    use Illuminate\Bus\Queueable;
    use Illuminate\Queue\SerializesModels;
    use Illuminate\Queue\InteractsWithQueue;
    use Illuminate\Contracts\Queue\ShouldQueue;
    use Illuminate\Foundation\Bus\Dispatchable;
    
    class SendSMSMessages implements ShouldQueue
    {
        use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    
        // Your job initialization logic
        public function __construct()
        {
            //
        }
    
        // The core logic of your SMS sending job
        public function handle()
        {
            // Add your SMS sending code here
        }
    }
    
    • If implements ShouldQueue is missing, add it to the class declaration.
    • Make sure the use Illuminate\Contracts\Queue\ShouldQueue; import is present at the top of the file.
  3. Verify your queue setup
    Don't forget to configure your queue driver in .env (e.g., QUEUE_DRIVER=database or QUEUE_DRIVER=redis) and start the queue worker with one of these commands:

    # Listens for queue jobs and restarts automatically when code changes
    php artisan queue:listen
    
    # Processes queue jobs more efficiently, requires a restart after code changes
    php artisan queue:work
    

That's it! Your SendSMSMessages job will now be processed asynchronously via Laravel's queue system.

内容的提问来源于stack exchange,提问作者HItesh Tank

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:04:10