Download the PHP package mateusjunges/laravel-trackable-jobs without Composer

On this page you can find all versions of the php package mateusjunges/laravel-trackable-jobs. 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-trackable-jobs

Trackable Jobs For Laravel

Latest Version on Packagist Total Downloads Check & fix styling Continuous Integration

Sponsor my work!

If you think this package helped you in any way, you can sponsor me on GitHub!

Documentation

Installation and setup

To install this package, you must be running php v8.0 or higher, as well as laravel v9.x or higher.

Use composer:

You can publish the configuration file and the migration with this command:

Run php artisan migrate to migrate the table needed by this package, and now you are good to go!

Tracking Jobs

To start tracking your jobs, you just need to extend the base \Junges\TrackableJobs\TrackableJob class in the job you want to track. For example, let's say you want to track the status of ProcessPodcastJob:

This package will store the last status of your job, which can be created, queued, started, failed or finished. Also, it stores the started_at and finished_at timestamps for each tracked job.

To use it, you just need to pass any model to your Job constructor:

Once this trait is added to your job, your job progress will be persisted to the database. You can configure the table name by publishing this package configuration file:

This command will create a new config file in config/trackable-jobs.php, with this content:

Associating tracked jobs with a model

Associating a tracked job with a model is specially useful if you want to track the steps to achieve something. Let's say you are using job chains for releasing your new podcast. Here's an example:

Job chain are a nice and fluent way of saying "Run this jobs sequentially, one after the previous one is complete.".

In this case, it might be useful to relate all jobs in this chain to the main $podcast model. You can achieve that by overriding the trackableType and trackableKey in each one of the jobs in your chain:

Now, this package will automatically relate tracked jobs to the podcast model passed in the job constructor.

You can get all the steps by adding a relationship to your Podcast model:

Now, you can have the status of each job that should be processed to release your podcast:

Persist job Output

To persist the output of your job to the database, you only need to return something from your job. By default, if your job throws an exception, the output stored in the database will be the message of the given exception. If your job finishes successfully, you don't have to return anything, but you can store it's output by just returning something after the job is done. For example:

The string Job finished successfully will be stored as the output of this job.

The output returned by your job will be stored as json.

Extending the tracked job model

If, for some reason, you need to use your own custom model to the TrackedJob table, you can just create a new model and extend the existing Junges\TrackableJobs\Models\TrackedJob::class. Then, you need to bind the Junges\TrackableJobs\Contracts\TrackableJobContract to the new model, within your AppServiceProvider:

Using UUIDs

To use UUIDs with this package, the only additional configuration you need to do is change the using_uuid to true, in config/trackable-jobs.php. Then it will automatically start using UUID's to store the tracked jobs and, if the model related to the tracked job also uses UUID, it will be stored to the database in the trackable_id field.

Pruning tracked jobs

If you want to prune your old tracked jobs, you can set the prunable_after config with the amount of days you want your models to keep in your database. For example, if you set the prunable_after to 30, all models older than 30 days will be deleted.

Tests

Run composer test to test this package.

Contributing

Thank you for consider contributing for the Laravel Trackable Jobs package! The contribution guide can be found here.

Changelog

Please see the changelog for more information about the changes on this package.

Credits

License

The laravel trackable jobs is open-sourced software licensed under the terms of MIT License. Please see the license file for more information.


All versions of laravel-trackable-jobs with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^11.0
illuminate/queue Version ^11.0
illuminate/database Version ^11.0
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 mateusjunges/laravel-trackable-jobs contains the following files

Loading the files please wait ....