| Install | |
|---|---|
composer require 3neti/form-flow |
|
| Latest Version: | v1.7.15 |
| PHP: | ^8.2 |
Driver-based form flow orchestration system with DirXML-style mapping for Laravel applications.
Install via Composer:
composer require 3neti/form-flow
Publish the configuration file:
php artisan vendor:publish --tag=form-flow-config
Publish driver examples:
php artisan vendor:publish --tag=form-flow-drivers
Publish Vue components:
php artisan vendor:publish --tag=form-flow-views
Or publish everything at once:
php artisan vendor:publish --tag=form-flow-core
The package configuration is located at config/form-flow.php:
return [
'route_prefix' => env('FORM_FLOW_ROUTE_PREFIX', 'form-flow'),
'middleware' => ['web'],
'driver_directory' => config_path('form-flow-drivers'),
'session_prefix' => 'form_flow',
'handlers' => [
// Plugin handlers register themselves via service providers
],
];
Define a flow driver in config/form-flow-drivers/my-flow.yaml:
name: my-flow
title: My Form Flow
steps:
- handler: splash
config:
title: Welcome
message: Let's get started
- handler: form
config:
title: User Information
fields:
- name: full_name
type: text
label: Full Name
validation: required|string|max:255
use Illuminate\Support\Facades\Http;
$response = Http::post('/form-flow/start', [
'reference_id' => 'unique-transaction-id',
'steps' => [
['handler' => 'splash', 'config' => [...]],
['handler' => 'form', 'config' => [...]],
],
'callbacks' => [
'on_complete' => 'https://your-app.com/api/flow-complete',
'on_cancel' => 'https://your-app.com/api/flow-cancelled',
],
]);
$flowUrl = $response->json('flow_url');
The package automatically registers these routes:
POST /form-flow/start - Start a new flowGET /form-flow/{flow_id} - Show current stepPOST /form-flow/{flow_id}/step/{step} - Update step dataPOST /form-flow/{flow_id}/complete - Complete flowPOST /form-flow/{flow_id}/cancel - Cancel flowDELETE /form-flow/{flow_id} - Destroy flow stateCreate custom handlers by implementing FormHandlerInterface:
use LBHurtado\FormFlowManager\Contracts\FormHandlerInterface;
class MyCustomHandler implements FormHandlerInterface
{
public function getName(): string
{
return 'my-custom';
}
public function handle(Request $request, FormFlowStepData $step, array $context = []): array
{
// Process step data
return ['processed' => true];
}
public function render(FormFlowStepData $step, array $context = [])
{
return inertia('MyCustomView', [...]);
}
// ... other methods
}
Register in your service provider:
public function boot(): void
{
$handlers = config('form-flow.handlers', []);
$handlers['my-custom'] = MyCustomHandler::class;
config(['form-flow.handlers' => $handlers]);
}
The package includes ready-to-use Vue components:
GenericForm.vue - Generic form rendererSplash.vue - Splash screen handlerComplete.vue - Flow completion pageMissingHandler.vue - Fallback for missing handlerscomposer test
Please see CHANGELOG for recent changes.
The MIT License (MIT). Please see License File for more information.