Laravel Artisan Generator Command: The make:job Command

December 7, 2016 —John Koster

The make:job command is used to create a new job class. A name must be supplied that will be used as the name of the newly generated class and file. An optional --sync flag can be set to indicate that the created job should be synchronous. Generated job classes are stored in the app/Jobs directory.

The following examples demonstrate how to call the make:job command:

1# Create an asynchronous job (default).
2php artisan make:job AsynchronousJob
3 
4# Create a synchronous job.
5php artisan make:job SynchronousJob --sync

Synchronous jobs do not implement the Illuminate\Contracts\Queue\ShouldQueue interface.

This command will not overwrite any existing job classes. Instead an error stating Job already exists! will be displayed.

The make:job command is also capable of generated namespaced classes. Accomplish this by separating namespace sections using the \ when supplying the job name. A nested directory will be created and the correct namespace will be set on the generated class.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.