- Can I use this workflow bundle directly in Laravel, or is it strictly for Symfony?
- This bundle is Symfony-centric and requires Symfony components like AppKernel, YAML config, and KnpMenuBundle. For Laravel, you’ll need to abstract Symfony dependencies (e.g., via a facade or service provider) or use the underlying `symfony/workflow` package directly. Start with a proof-of-concept for a single workflow before full adoption.
- What Laravel alternatives exist for workflow management without Symfony overhead?
- Consider Laravel-native packages like `spatie/laravel-activitylog` (for auditing) combined with custom state machines, or `laravel-state-machine`. For Symfony-like workflows, evaluate `spatie/laravel-workflow` if available, or build a lightweight solution using Eloquent accessors, observers, and events.
- How do I install this bundle in a Laravel project?
- This bundle isn’t Laravel-compatible out of the box. Add it via Composer (`dev-master`), but you’ll need to create a Laravel service provider to bridge Symfony components (e.g., WorkflowManager) and map Symfony routes to Laravel’s `routes/web.php`. Avoid `AppKernel` and use Laravel’s config system instead of YAML.
- Does this bundle support Eloquent ORM, or only Doctrine?
- The bundle assumes Doctrine ORM (e.g., `db_driver: orm`). Eloquent is compatible for basic workflows, but Doctrine-specific features (like lifecycle callbacks) may require middleware or custom Eloquent events. Test with a simple workflow first to identify gaps.
- How do I configure workflows in Laravel’s `config/workflow.php` instead of Symfony’s YAML?
- You’ll need to create a Laravel service that loads workflow definitions from `config/workflow.php` and passes them to the Symfony Workflow component. Example: Use `Workflow::createFromArray()` with your PHP config array. Avoid YAML entirely by converting Symfony’s config format to Laravel’s array syntax.
- What’s the best way to handle workflow history queries in production?
- The bundle provides an AJAX endpoint (`execution_history`) for dynamic history fetching. For production, optimize Doctrine queries (e.g., add indexes to `workflow_entity_id` and `transitioned_at` columns) or use Eloquent’s `with()` to eager-load related data. Cache frequent history requests if your workflows are read-heavy.
- Can I replace KnpMenuBundle’s GUI with Laravel Blade or Inertia.js?
- Yes, the bundle’s Twig helpers (`workflow_configuration`, `workflow_history`) can be adapted for Blade by extending the underlying Symfony Workflow templates. For Inertia.js, fetch workflow data via the AJAX endpoint and render custom Vue/React components. Skip KnpMenuBundle entirely if visualization isn’t critical.
- How do I integrate async workflow transitions (e.g., email notifications after state changes)?
- The bundle depends on `AbcJobBundleBundle` for async tasks. In Laravel, replace it with `laravel-horizon` or `spatie/laravel-queue`. Trigger jobs in workflow guards or transitions using Laravel’s queue system. Example: Dispatch a `SendApprovalEmail` job when the `approve` transition fires.
- What Laravel versions and PHP versions does this bundle support?
- The bundle targets Symfony 3/4 and PHP 7.1+. Laravel compatibility isn’t guaranteed, but the underlying `symfony/workflow` component works with Laravel 7+ and PHP 7.3+. Test thoroughly, as Symfony’s service container differs from Laravel’s. Avoid `dev-master` for production; fork and stabilize if needed.
- Are there any known issues with concurrent workflow transitions or race conditions?
- The bundle doesn’t document handling for concurrent transitions. In Laravel, add database transactions around workflow transitions to prevent race conditions. For high-contention workflows, consider optimistic locking (e.g., `selectForUpdate()`) or implement a custom guard to validate state before transitions.