Skip to content

[12.x] Add documentation for make:job command options: --batched and --sync #10486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ php artisan make:job ProcessPodcast

The generated class will implement the `Illuminate\Contracts\Queue\ShouldQueue` interface, indicating to Laravel that the job should be pushed onto the queue to run asynchronously.

### Create a Synchronous Job

If you want the job to run immediately (synchronously) instead of being queued, you can use the `--sync` option:

```bash
php artisan make:job ProcessPodcast --sync
```

This will generate a job class that **does not** implement the `Illuminate\Contracts\Queue\ShouldQueue` interface. The job will be executed in the same process as the request, which is useful for simple tasks or development/testing environments.

> [!NOTE]
> Job stubs may be customized using [stub publishing](/docs/{{version}}/artisan#stub-customization).

Expand Down Expand Up @@ -1473,6 +1483,12 @@ class ImportCsv implements ShouldQueue
}
```

You can also create a batchable job using the `make:job` Artisan command with the `--batched` option:

```shell
php artisan make:job ProcessPodcast --batched
```

<a name="dispatching-batches"></a>
### Dispatching Batches

Expand Down