Laravel Packages

Manage Job Workflows with Venture

Published
Manage Job Workflows with Venture image

Venture is a package to help you build and manage complex, asynchronous workflows in your Laravel applications. Here’s an example from the documentation which illustrates a workflow defined when publishing a podcast:

Workflow::new('Publish new podcast')
    ->addJob(new ProcessPodcast($podcast))
    ->addJob(new OptimizePodcast($podcast))
    ->addJob(new PublishPodcastOnTransistorFM($podcast), [
        ProcessPodcast::class,
        OptimizePodcast::class
    ]);

In the above example, publishing the podcast depends on the processing and optimization of job completion.

At the heart of this package is the WorkflowStep trait that you’ll need to add to jobs to use them within a workflow. This trait enables Venture to track a job’s dependencies and other dependent jobs.

Another neat feature is performing an action after a workflow has finished:

Workflow::new('Example Workflow')
    ->addJob(new ExampleJob())
    ->then(function (Workflow $workflow) {
        // This will get called once every job in the workflow has finished.
        // It gets passed the workflow instance.
    })
    ->start();

// You can also use an invokable class with the `then()` method.
class SendNotification
{
    public function __invokable(Workflow $workflow)
    {
        // Do something with the workflow...
    }
}

Workflow::new('Example Workflow')
    ->addJob(new ExampleJob())
    ->then(new SendNotification())
    ->start();

Venture also helps you deal with failures in a workflow, failed steps, and things like canceling the workflow. You can learn more about this package, get full installation instructions, and view the source code on GitHub at ksassnowski/venture.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

acquaintsoft logo
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech

The latest

View all →
PHP 8.6 is released!  image

PHP 8.6 is released!

Read article
Laravel Warrant: Row-Level Permissions With Eloquent image

Laravel Warrant: Row-Level Permissions With Eloquent

Read article
JSON Schema Validation Rules and a RetryFor Attribute in Laravel 13.43 image

JSON Schema Validation Rules and a RetryFor Attribute in Laravel 13.43

Read article
Durable Workflow: Long-Running Workflows for Laravel image

Durable Workflow: Long-Running Workflows for Laravel

Read article
Session Replay for Laravel: Self-Hosted Browser Recordings image

Session Replay for Laravel: Self-Hosted Browser Recordings

Read article
Laravel AI SDK 1.4 Lets Agents Recover From Tool Failures image

Laravel AI SDK 1.4 Lets Agents Recover From Tool Failures

Read article