- Can I use this bundle directly in Laravel, or is it strictly Symfony 2.x?
- This bundle is designed for Symfony 2.x and won’t work out-of-the-box in Laravel due to architectural differences like Doctrine ORM vs. Eloquent and Symfony’s EventDispatcher vs. Laravel’s middleware. You’d need to rewrite domain resolution logic (e.g., replacing Symfony’s `RequestStack` with Laravel’s `Request` facade) and adapt the `DomainTrait` to Eloquent models via query scopes or observers.
- How does the bundle enforce domain isolation for entities?
- The bundle uses the `DomainTrait`, which filters entities by a `domain` column (assumed to be added manually) during queries. Entities inheriting this trait are automatically restricted to the current request’s domain, e.g., `app1.example.com` can only access records where `domain = 'app1'`. This is rigid—entities must inherit the trait to be domain-isolated.
- What Laravel alternatives exist for multi-domain/subdomain management?
- For Laravel, consider packages like `stancl/tenancy` (for multi-tenancy with shared databases), `spatie/laravel-multitenancy` (database-per-tenant), or custom middleware/query scopes for domain-based filtering. Unlike this Symfony bundle, these solutions often support dynamic tenant switching, shared entities, and middleware-based context handling.
- Do I need to add a `domain` column to my database tables manually?
- Yes, the bundle assumes you’ve added a `domain` column (e.g., `VARCHAR`) to your entities’ tables. This column stores the subdomain (e.g., `app1`, `app2`) and is used by the `DomainTrait` to filter records. No migrations are provided—you’ll need to handle this manually or via a custom migration.
- Will this bundle work with Laravel’s Eloquent ORM?
- No, this bundle is built for Doctrine ORM (Symfony 2.x) and won’t integrate with Eloquent. To replicate its behavior in Laravel, you’d need to create a custom query scope or model observer that filters records by a `domain` column, similar to how the `DomainTrait` works in Doctrine.
- How do I handle a default domain (e.g., `example.com`) vs. subdomains (e.g., `app1.example.com`)?
- The bundle doesn’t explicitly document this, but you’d likely set the default domain (e.g., `NULL` or a string like `default`) in the `domain` column for shared records. Subdomains would use values like `app1`, `app2`. You’d need to configure domain resolution logic (e.g., parsing `Request::getHost()`) to map `example.com` to the default domain.
- Can I use this bundle for API routes or queued jobs where no request context exists?
- No, the bundle relies on Symfony’s `RequestStack` to determine the current domain, which isn’t available in API routes or queued jobs. You’d need to manually pass the domain context (e.g., via a service container or job data) or implement a fallback mechanism, like defaulting to a `NULL` domain for shared records.
- What Laravel versions are supported, or is this a Symfony-only solution?
- This is a Symfony 2.x-only solution with no Laravel support. Even Symfony 3.x/4.x/5.x/6.x would require adjustments (e.g., dependency overrides for `symfony/class-loader`). For Laravel, you’d need to build a custom solution or adapt the bundle’s core logic, which isn’t recommended due to its tight coupling with Symfony components.
- How do I test domain-specific behavior in my application?
- Testing would require mocking Symfony’s `RequestStack` to simulate different domains (e.g., `app1.example.com`, `app2.example.com`). In Laravel, you’d mock the `Request` facade or use middleware to set a `domain` context for tests. The bundle’s lack of documentation makes reverse-engineering test cases challenging.
- Does this bundle handle URL generation or asset rewriting for domains?
- No, the bundle only filters entity visibility by domain—it doesn’t handle domain-aware URL generation (e.g., `route('page', ['domain' => 'app1'])`), redirects between domains, or rewriting asset paths (e.g., CSS/JS with domain-specific hashes). You’d need to implement this separately, likely via middleware or view composers.