Manage Job Workflows with Venture

Manage Job Workflows with Venture

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.

Filed in: News / packages

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Laravel Senior Developer
Remote, Canada Only
BeMo Academic Consulting
Senior Fullstack Developer / Architect (w/m/d)
Remote / Munich - Germany
envivo.select GmbH
Medior full stack developer (Laravel)
Deventer (or remote) in the Netherlands, Dutch speaking required.
MSML B.V.
Senior Full Stack PHP Developer (Laravel)
Remote
MAPPEN
Senior Laravel Developer
Remote
ACTO