Download the PHP package spatie/laravel-artisan-dispatchable without Composer

On this page you can find all versions of the php package spatie/laravel-artisan-dispatchable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-artisan-dispatchable

Dispatch Laravel jobs via Artisan

Latest Version on Packagist Total Downloads

This package can register jobs as Artisan commands. All you need to do is let your job implement the empty ArtisanDispatchable interface.

This allows the job to be executed via Artisan.

Why we created this package

Laravel's scheduler will perform all tasks sequentially. When you add a scheduled task to the scheduler, the task should perform its work as fast as possible, so no other tasks will have to wait.

If you have a task that needs to run every minute and its runtime is close to a minute, you should not use a simple Artisan command, as this will result in the delay of all other minute-ly tasks.

Long-running tasks should be performed by jobs that perform their work on the queue. Laravel has the ability to schedule queued jobs. This way, those tasks will not block the scheduler.

`

The downside of this approach is that you cannot run that job via Artisan anymore. You have to choose between using an artisan command + blocking the scheduler on the one hand, and job + not blocking the scheduler on the other hand.

Using our package, you don't have to make that choice anymore. When letting your job implement Spatie\ArtisanDispatchable\Jobs\ArtisanDispatchable, you will not block the scheduler and can still execute the logic via Artisan.

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Installation

You can install the package via composer:

Optionally, you can publish the config file with:

This is the contents of the published config file:

Usage

All you need to do is let your job implement the empty ArtisanDispatchable interface.

This allows the job to be executed via Artisan.

This job will not be queued, but will be immediately executed inside the executed artisan command.

Queueing jobs via Artisan

If you want to put your job on the queue instead of executing it immediately, add the queued option.

Passing arguments to a job

If your job has constructor arguments, you may pass those arguments via options on the artisan command.

Via artisan, you can call the job like this

Using Eloquent models as arguments

If your job argument is an eloquent model, you may pass the id of the model to the artisan command option.

Here's how you can execute this job with podcast id 1234

Customizing the name of the command

By default, the artisan command name of a job, is the base name of job in kebab-case.

You can set a custom name by setting a property named artisanName on your job.

This job can now be executed with this command:

Customizing the description of the command

To add a description to the list of artisan commands, add a property $artisanDescription to your job.

Prefixing all commands

You can specify a prefix in the command_name_prefix key of the config file. When this is for example set to my-custom-prefix, then you would be able to call MyDispatchableJob with this command:

Caching discovered jobs

This package can automatically discover jobs that implement ArtisanDispatchable and what their artisan command should be through looping through all classes and performing some reflection. In a local environment this is perfect, as the performance hit is not too bad, and you don't have to do anything special besides letting your job implement ArtisanDispatchable.

In a production environment, you probably don't want to loop through all classes on every request. The package contains a command to cache all discovered jobs.

You probably want to call that command during your deployment of your app. This will create cache file at the location specified in the cache_file key of the artisan-dispatchable config file.

Should you want to clear the cache, you can execute this command:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-artisan-dispatchable with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/console Version ^10.0|^11.0
illuminate/contracts Version ^10.0|^11.0
spatie/laravel-package-tools Version ^1.16.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package spatie/laravel-artisan-dispatchable contains the following files

Loading the files please wait ....