- Can SyliusResourceBundle work with Laravel’s Eloquent ORM, or is it strictly for Doctrine?
- While the bundle is built for Doctrine, you can adapt it to Eloquent by wrapping Doctrine’s `ObjectManager` and `ObjectRepository` interfaces behind Laravel facades or service container bindings. This requires custom bridge logic but enables reuse of the CRUD abstraction layer. For full compatibility, consider abstracting repository logic via interfaces.
- How do I install SyliusResourceBundle in a Laravel project?
- Install via Composer with `composer require sylius/resource-bundle`, then bridge Symfony dependencies (e.g., `symfony/dependency-injection`) using Laravel’s `bind()` method or a package like `spatie/laravel-symfony-support`. Configure routes manually in `RouteServiceProvider` since Symfony’s routing differs from Laravel’s. No official Laravel installer exists.
- Does this bundle support Laravel’s API resources (JSON responses) or is it Twig-focused?
- The bundle is format-agnostic, so you can use it for APIs by returning JSON responses in controllers. However, Twig templates must be replaced with Blade or API responses. It’s ideal for headless Laravel apps or internal tools where CRUD is decoupled from presentation. For APIs, pair it with Laravel’s `ResourceController` or custom JSON responses.
- What Laravel versions and PHP versions does SyliusResourceBundle support?
- The bundle requires PHP 8.2+ (for v1.11.x) and works with Laravel 10/11 if Symfony dependencies are managed. Earlier versions (e.g., v1.10) may support older PHP/Laravel but lack newer features. Always check the [Sylius docs](https://github.com/Sylius/SyliusResourceBundle) for version-specific requirements.
- How do I handle state machines (e.g., workflows) in Laravel if this bundle uses Symfony’s state machines?
- Map Symfony’s state machines to Laravel’s policies or custom authorization logic (e.g., `spatie/laravel-permission`). Use Laravel’s event system to trigger workflow transitions or adapt the bundle’s state machine logic via interfaces. For complex workflows, consider hybrid approaches like using the bundle’s validation while handling state transitions in Laravel.
- Is SyliusResourceBundle suitable for admin panels, or is it only for APIs/internal tools?
- This bundle is **not** an admin generator—it’s low-level and requires manual UI layering. For admin panels, use Laravel-native tools like Filament, Backpack, or Nova. SyliusResourceBundle excels in APIs, internal tools, or headless apps where CRUD is decoupled from presentation. It provides controllers and filtering/sorting but no forms or grids.
- How do I integrate Symfony’s event dispatcher with Laravel’s events?
- Use Laravel’s event system to listen for Symfony events by mapping them manually (e.g., `ResourceCreated` → `entity.created`). Alternatively, create a listener adapter to bridge Symfony’s `EventDispatcher` to Laravel’s `Event` facade. This ensures pre/post-operation hooks work seamlessly without tight coupling.
- Are there performance concerns when using SyliusResourceBundle in production?
- The bundle adds minimal overhead if used for CRUD abstraction. For filtering/sorting, leverage Doctrine’s native optimizations or Laravel’s query builders. If using Doctrine, profile with tools like Laravel Debugbar or Blackfire. For large datasets, consider caching (e.g., `spatie/laravel-query-builder` for paginated queries).
- What alternatives exist for CRUD abstraction in Laravel if I don’t want to use Symfony components?
- For Laravel-native CRUD, consider `spatie/laravel-query-builder` (filtering/sorting), `laravel-breeze` (auth + CRUD scaffolding), or packages like Filament (admin panels). For state machines, use `spatie/laravel-permission` or custom policies. If you need Doctrine features (e.g., state machines), evaluate `doctrine/orm` with Laravel adapters.
- How do I handle routing conflicts between Symfony’s and Laravel’s routing systems?
- Symfony’s routing (e.g., `yields`) differs from Laravel’s. Register routes manually in `RouteServiceProvider` with prefixes (e.g., `/api/resource`) or middleware to isolate paths. For RESTful APIs, use Laravel’s built-in routing conventions. Avoid mixing Symfony’s `routing` component with Laravel’s router to prevent conflicts.