symfony workflow component for laravel7 and 8 ,php 7 and 8

Overview

Laravel workflow Build Status

Use the Symfony Workflow component in Laravel8,PHP7,PHP8 This repository based on @brexis,his project since 2019-09 No longer maintained. So i modify the code and publish it.

Installation

composer require cage/laravel-workflow

Configuration

Publish the config file

    php artisan vendor:publish --provider="Cage\LaravelWorkflow\WorkflowServiceProvider"

Configure your workflow in config/workflow.php

Use the WorkflowTrait inside supported classes

<?php
namespace App;

use Illuminate\Database\Eloquent\Model;
use Cage\LaravelWorkflow\Traits\WorkflowTrait;

class BlogPost extends Model
{
  use WorkflowTrait;
}

Usage

<?php

use App\Models\BlogPost;
use Workflow;

$post        = BlogPost::find(1);
$workflow    = $post->workflow_get();// or $workflow = Workflow::get($post);
$workflow->can($post, 'publish'); //  False
$workflow->can($post, 'to_review'); // True
$transitions = $workflow->getEnabledTransitions($post);// Get the transitions
$definition  = $workflow->getDefinition();// Get the definition
$places      = $workflow->getMarking($post)->getPlaces();// // Get the current places
$metadata    = $workflow->getMetadataStore();// Get the metadata

// Apply a transition
$workflow->apply($post, 'to_review');
$post->save(); // Don't forget to persist the state

Use the events

Register at app/Providers/EventServiceProvider.php

protected $subscribe = [
        BlogPostWorkflowSubscriber::class,
    ];

Then you can subscribe to an event Create Listener at app/Listeners/BlogPostWorkflowSubscriber.php

<?php

namespace App\Listeners;

use Cage\LaravelWorkflow\Events\GuardEvent;

class BlogPostWorkflowSubscriber
{
    public function onGuard(GuardEvent $event){}

    public function onLeave($event)
    {
        // The event can also proxy to the original event
        $subject = $event->getOriginalEvent()->getSubject();
    }

    public function onTransition($event) {}

    public function onEnter($event) {}

    public function onEntered($event) {}

    public function subscribe($events)
    {
        $events->listen(
            'Cage\LaravelWorkflow\Events\GuardEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onGuard'
        );

        $events->listen(
            'Cage\LaravelWorkflow\Events\LeaveEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onLeave'
        );

        $events->listen(
            'Cage\LaravelWorkflow\Events\TransitionEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onTransition'
        );

        $events->listen(
            'Cage\LaravelWorkflow\Events\EnterEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onEnter'
        );

        $events->listen(
            'Cage\LaravelWorkflow\Events\EnteredEvent',
            'App\Listeners\BlogPostWorkflowSubscriber@onEntered'
        );
    }

}

Dump Workflows

Symfony workflow uses GraphvizDumper to create the workflow image. You may need to install the dot command of Graphviz

php artisan workflow:dump straight --class App\\Models\\BlogPost --path workflows  --format=svg

For More Information

https://symfony.com/doc/current/workflow.html https://github.com/brexis/laravel-workflow

You might also like...
Livewire component that provides you with a modal that supports multiple child modals while maintaining state.
Livewire component that provides you with a modal that supports multiple child modals while maintaining state.

About LivewireUI Modal LivewireUI Modal is a Livewire component that provides you with a modal that supports multiple child modals while maintaining s

Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About LivewireUI Spotlight LivewireUI Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel application.

Asset Component is a port of Laravel 3 Asset for Orchestra Platform.

Asset Component is a port of Laravel 3 Asset for Orchestra Platform. The component main functionality is to allow asset declaration to be handle dynamically and asset dependencies can be resolve directly from the container. It however is not intended to becoma an asset pipeline package for Laravel, for such purpose we would recommend to use Grunt or Gulp.

A TALL-based Laravel Livewire component to replace the (multiple) select HTML input form with beautiful cards.
A TALL-based Laravel Livewire component to replace the (multiple) select HTML input form with beautiful cards.

TALL multiselect cards A TALL-based Laravel Livewire component to replace the (multiple) select HTML input form with beautiful cards. Table of content

Laravel Composable View Composers Package - Compose View Composers from Component Composers
Laravel Composable View Composers Package - Compose View Composers from Component Composers

Laravel Virtuoso Laravel Composable View Composers Package Increase flexibility and reduce code duplication by easily composing complex View Composers

Customizable Feedback Component for Laravel
Customizable Feedback Component for Laravel

Laravel Feedback Component allows you to easily implement a Customer Feedback component on your website. It is build with VueJS but can be implemented in any kind of Laravel Project. You just need to drop a few lines in your layout.

Laravel Livewire component to show Events in a good looking monthly calendar
Laravel Livewire component to show Events in a good looking monthly calendar

Livewire Calendar This package allows you to build a Livewire monthly calendar grid to show events for each day. Events can be loaded from within the

Livewire component that provides you with a modal that supports multiple child modals while maintaining state.
Livewire component that provides you with a modal that supports multiple child modals while maintaining state.

About Wire Elements Modal Wire Elements Modal is a Livewire component that provides you with a modal that supports multiple child modals while maintai

Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.

About Wire Elements Spotlight Wire Elements Spotlight is a Livewire component that provides Spotlight/Alfred-like functionality to your Laravel applic

Owner
null
Rapidly speed up your Laravel workflow with generators

Fast Workflow in Laravel With Custom Generators This Laravel package provides a variety of generators to speed up your development process. These gene

Jeffrey Way 22 Oct 28, 2022
Llum illuminates your Laravel projects speeding up your Github/Laravel development workflow

Llum illuminates your Laravel projects speeding up your Github/Laravel development workflow

Sergi Tur Badenas 110 Dec 25, 2022
A new way of Running Tinker. Simplify the Web Artisan's workflow.

Tinkerun A new way of Running Tinker. Simplify the Web Artisan's workflow. inspired by Tinkerwell Download links Github Releases ?? If you are using V

Tinkerun 327 Dec 29, 2022
Laminas\Console is a component to design and implement console applications in PHP.

laminas-console This package is abandoned and will receive no further development! We recommend using laminas/laminas-cli. Laminas\Console is a compon

Laminas Project 10 Nov 27, 2021
Component for reading phar.io manifest information from a PHP Archive (PHAR)

Manifest Component for reading phar.io manifest information from a PHP Archive (PHAR). Installation You can add this library as a local, per-project d

null 7.1k Jan 9, 2023
Laravel Livewire form component with declarative Bootstrap 5 fields and buttons.

Laravel Livewire Forms Laravel Livewire form component with declarative Bootstrap 5 fields and buttons. Requirements Bootstrap 5 Installation composer

null 49 Oct 29, 2022
Emmet like Abbreviation to generate and wrap Laravel Blade Component with markup

Laravel Blade Emerald Emmet like Abbreviation to generate and wrap Laravel Blade Component with markup ?? Features Generate HTML in a Blade file via p

Aqua 32 Sep 6, 2022
Livewire component for dependant and/or searchable select inputs

Livewire Select Livewire component for dependant and/or searchable select inputs Preview Installation You can install the package via composer: compos

Andrés Santibáñez 441 Dec 19, 2022
Laravel Livewire full page component routing.

Laravel Livewire Routes Laravel Livewire full page component routing. This package allows you to specify routes directly inside your full page Livewir

null 22 Oct 6, 2022
Laravel component to create gorgeous Charts.css charts.

Laravel component to create gorgeous Charts.css charts. This package will help you generate CSS only charts based on the Charts.css library. Installat

Maarten Paauw 105 Sep 26, 2022