soap / laravel-workflow-loader
This is my package laravel-workflow-loader
Fund package maintenance!
Soap
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
- zerodahero/laravel-workflow: ^4.0|^5.0
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/canvas: ^8.8||^9.1
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
README
This package extends zerodahero/laravel-workflow by adding option to store workflow configuration in database. Laravel workflow only support loading configuration form Laravel configuration. This package provides user to change workflow configuration without helping from developers.
Support us
You can suggest for any approvement, sponsor this project or make a pull request. I am happy to consider any recommendation. I am not a good programmer so my design may not be the best one. My background is not computer programming. I am an Electrical engineer.
Installation
You can install the package via composer:
composer require soap/laravel-workflow-loader
You can publish and run the migrations with:
php artisan vendor:publish --tag="workflow-loader-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="workflow-loader-config"
This is the contents of the published config file:
return [ 'loaders' => [ 'database' => [ 'tableNames' => [ 'workflows' => 'workflows', 'workflow_states' => 'workflow_states', 'workflow_transitions' => 'workflow_transitions', 'workflow_state_transitions' => 'workflow_state_transitions', ], 'class' => \Soap\WorkflowLoader\DatabaseLoader::class, ], ], ];
To use this package to load workflow configuration from database, you need to register workflow service provider provided by the package. Zerodahero 's workflow registry will be used to load configuration retreiving from database.
php artisan venodr:publish --tag="workflow-loader-provider"
This will copy the following WorkflowServiceProvider.php to application providers folder, ensure that it was included in application bootstrap. The following is the content of the file.
namespace App\Providers; use Illuminate\Support\ServiceProvider; class WorkflowServiceProvider extends ServiceProvider { public function register() {} public function boot() { $registry = app()->make('workflow'); $workflowLoaderRegistry = app()->make('workflowLoaderRegistry'); foreach ($workflowLoaderRegistry->all() as $workflow => $config) { $registry->addFromArray($workflow, $config); } } }
This package doesnot provide user interface for user to manage workflow configuration. By design it should be in separate package. I have a plan to create filament plugin to handle this.
Usage
After you have completed setup, create workflow configuration in database using your own way or provided by other package. Then use them like the one you use by zerohadero/laravel-workflow. Storing configuration in database is easy to develop workflow for user.
To Do
Curently guards should be created via event subscriber. I have a plan to use Symfony expression as upper guard layer. For example, you can write;
guard => $subject.isWaitingFor($user) || !$subject.isOwnedBy($user)
or
guard => $subject.isApprovers($user) || $subject.isReviewers($user)
Then the package will inject $subject and $user for you and use Symfony expression to evaluate blocking of the transition.
Testing
composer test
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.