PHP code example of teamzac / laravel-workflows

1. Go to this page and download the library: Download teamzac/laravel-workflows library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

teamzac / laravel-workflows example snippets




namespace App\Workflows;

use TeamZac\Workflows\AbstractWorkflow;

class TestWorkflow extends AbstractWorkflow
{
  protected $steps = [
      'App\Workflows\StepOne',
      'App\Workflows\StepTwo',
      'App\Workflows\StepThree',
    ];
}



namespace App\Providers;

use TeamZac\Workflow\Facades\Workflow;

class AppServiceProvider 
{
  public function boot() 
    {
    Workflow::extend('test-workflow', function() {
          return new \App\Workflows\TestWorkflow;
        });
  }
}
 artisan event:generate

$instance = TeamZac\Workflows\WorkflowInstance::create([
  'workflow' => 'test-workflow',
]);

// by calling run() directly on the instance
$instance->run();

// by passing it through the Workflow facade
Workflow::run($instance);

// by manually creating an instance of the Workflow driver, setting the instance, and calling run
Workflow::driver('test-workflow')->setInstance($instance)->run();

Workflow::test($workflowInstance, StepClass::class);
config/app.php
bash
php artisan vendor:publish --provider="TeamZac\Workflow\WorkflowServiceProvider"
bash
php artisan migrate
bash
// example
php artisan make:workflow App\\Workflows\\TestWorkflow
bash
php artisan workflow:generate test-workflow
$instance->run();
bash
php artisan vendor:publish --provider=TeamZac\\Workflows\\WorkflowServiceProvider --tag=config
bash
php artisan vendor:publish --provider=TeamZac\\Workflows\\WorkflowServiceProvider --tag=migrations
config/workflows.php