Error message:
Error message:
make
is the command to create a php file. The make:command
in your screenshot is to create a command line task. For example, if you create a command test
, you can execute php artisan test
on the command line to execute it. This test task.
Tasks used for queue execution generally use "Job". Create a job class through php artisan make:job
, and then use dispatch(new FooJob)
in the code to execute this task. If you need this job to be executed in a queue (asynchronously), the job class can implement ShouldQueue
. After adding the job to the queue, the queue itself must be started to ensure that the added job can be executed as planned. To start the queue, use the php artisan queue:work
command line. The official documentation explains these very clearly, and you can figure it out after reading it several times and trying it out.
https://laravel.com/docs/5.3/...
Chinese: https://laravel-china.org/doc...
When creating an event listener (listener) file, you can add parameters queued
to mark that this listener needs to be executed asynchronously in the queue, such as php artisan make:listener Foobar --queued
, defined in EventServiceProvider
The corresponding relationship between event and listener is established. Use the event()
function in the code to trigger an event. The framework will call its code based on the listener defined in the EventServiceProvider. If the listener is queued, it will be added to the queue.
Events, tasks, monitoring, and notifications in Laravel are all related to queues. But command (command line) has nothing to do with queues. Command can be understood as a command line tool executed after php artisan
. The command line tool can be added to the system's scheduled task cron to execute according to the planned time, such as restarting the server at 3 am every day. Laravel provides a convenient method to implement system cron scheduled tasks, which can be written in the schedule
method in app/Console/Kernel.php
.
The --queued option does not exist, what do you want to do