PHP code example of briefley / filament-workflow-builder

1. Go to this page and download the library: Download briefley/filament-workflow-builder 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/ */

    

briefley / filament-workflow-builder example snippets


return [
    'workflow_jobs' => [
        'hello_world_job' => [
            'label' => 'Hello World Job',
        ],
    ],

    'step_executors' => [
        'hello_world_job' => App\Workflow\Executors\HelloWorldStepExecutor::class,
    ],
];



namespace App\Workflow\Executors;

use Briefley\WorkflowBuilder\Contracts\WorkflowStepExecutor;
use Briefley\WorkflowBuilder\DTO\StepExecutionResult;
use Briefley\WorkflowBuilder\Models\WorkflowRunStep;
use Illuminate\Support\Facades\Log;

class SendReportStepExecutor implements WorkflowStepExecutor
{
    public function execute(WorkflowRunStep $runStep): StepExecutionResult
    {
        // Run your business logic here (API call, file export, DB work, etc).
        Log::info('Report step executed', [
            'workflow_run_id' => $runStep->workflow_run_id,
            'workflow_run_step_id' => $runStep->id,
        ]);

        return StepExecutionResult::succeeded(meta: [
            'report_id' => 123,
        ]);
    }
}



use Briefley\WorkflowBuilder\Contracts\ContextAwareWorkflowStepExecutor;
use Briefley\WorkflowBuilder\DTO\StepExecutionResult;
use Briefley\WorkflowBuilder\DTO\WorkflowStepExecutionContext;
use Briefley\WorkflowBuilder\Models\WorkflowRunStep;

class SendEmailsFromCsvStepExecutor implements ContextAwareWorkflowStepExecutor
{
    public function execute(WorkflowRunStep $runStep): StepExecutionResult
    {
        // Backward-compatible fallback when context is not available.
        return StepExecutionResult::failed('Missing context.');
    }

    public function executeWithContext(
        WorkflowRunStep $runStep,
        WorkflowStepExecutionContext $context,
    ): StepExecutionResult {
        $csvPath = $context->latestValueForStepType('generate_fake_users_csv_job', 'csv_path');

        if (! is_string($csvPath) || $csvPath === '') {
            return StepExecutionResult::failed('CSV path not found.');
        }

        // Continue with your step logic...
        return StepExecutionResult::succeeded();
    }
}

return [
    'workflow_jobs' => [
        'send_report_job' => [
            'label' => 'Send Report Job',
        ],
    ],

    'step_executors' => [
        'send_report_job' => App\Workflow\Executors\SendReportStepExecutor::class,
    ],
];

Schedule::command('workflow-builder:dispatch-due')->everyMinute();

->plugin(\Briefley\WorkflowBuilder\WorkflowBuilderPlugin::make())
bash
php artisan vendor:publish --tag=workflow-builder-config
php artisan vendor:publish --tag=workflow-builder-migrations
php artisan migrate
bash
php artisan schedule:work
php artisan queue:work