- Can I use sylius/customer in a Laravel project without Sylius eCommerce?
- Yes, sylius/customer is a standalone component from the Sylius suite and works independently. It’s designed for modular integration, so you can use its customer management features (addresses, groups, billing/shipping) without adopting the full Sylius stack. Just install via Composer and configure it for Laravel’s ecosystem.
- What Laravel versions does sylius/customer support?
- sylius/customer is framework-agnostic but integrates with Laravel via Symfony bridges (e.g., spatie/laravel-symfony-support). It requires PHP 8.0+ and works with Laravel 9/10, though you’ll need to manually handle Doctrine ORM or Eloquent conflicts. Check the [Sylius docs](https://docs.sylius.com) for compatibility notes.
- How do I handle Doctrine ORM conflicts with Laravel’s Eloquent?
- sylius/customer uses Doctrine ORM by default, which conflicts with Eloquent. Mitigate this by either: 1) Using `laravel-doctrine/orm` to unify both ORMs, or 2) Manually mapping Sylius entities to Eloquent models (higher maintenance). Avoid mixing them in the same migration or model layer to prevent collisions.
- Does sylius/customer support multi-addresses, billing plans, or customer groups?
- Absolutely. sylius/customer is built for granular customer profiles, including multiple addresses (billing/shipping), customer groups (e.g., VIP tiers), and custom attributes. This goes beyond Laravel’s default `users` table, making it ideal for B2B platforms or complex B2C workflows.
- How do I integrate Sylius’ security system with Laravel’s Auth?
- Use `spatie/laravel-symfony-support` to bridge Sylius’ Symfony-based security (e.g., roles, permissions) with Laravel’s Auth. For API tokens, pair it with Laravel Sanctum. Sylius events (e.g., `CustomerRegistered`) can trigger Laravel listeners via the Event facade, ensuring seamless authentication flow.
- Will sylius/customer work with Laravel’s API resources and Sanctum?
- Yes, sylius/customer is API-first and integrates well with Laravel Sanctum for token-based authentication. Use Laravel’s API Resources to transform Sylius entities (e.g., `Customer`, `Address`) into JSON responses. Sylius’ REST/GraphQL APIs can coexist with Laravel’s API layer.
- Are there performance concerns with Sylius’ event-driven architecture?
- Sylius uses events (e.g., `CustomerCreated`, `AddressAdded`) for extensibility, which adds minimal overhead if optimized. For production, disable unused events or batch them. Test under load to ensure latency doesn’t impact critical paths, especially in high-traffic applications.
- What’s the best way to test sylius/customer in Laravel?
- Use `orchestra/testbench` to test Sylius components in Laravel, as it provides Symfony kernel compatibility. Mock Sylius services (e.g., `CustomerRepository`) in PHPUnit tests. For database tests, use Laravel’s `DatabaseMigrations` trait with Sylius’ Doctrine fixtures.
- Can I migrate from Laravel’s built-in Auth to sylius/customer?
- Yes, but plan for a phased migration. Start by extending Laravel’s `User` model to include Sylius’ `Customer` traits or entities. Use a hybrid approach (e.g., Sylius for addresses/groups, Laravel Auth for core login) until fully transitioned. Backup data before schema changes.
- What alternatives exist for advanced customer management in Laravel?
- Alternatives include: 1) `spatie/laravel-permission` for roles/permissions (lighter than Sylius), 2) `laravel-billing/billing` for subscriptions, or 3) custom Eloquent models with traits for addresses. Sylius stands out for its DDD alignment, API-first design, and pre-built features like customer groups and multi-addresses.