- Can I use this package in Laravel without Symfony installed?
- Yes, the package leverages Symfony AI’s abstractions, which work independently of the full Symfony framework. Laravel’s service container and Composer autoloading handle the integration, so you only need the `symfony/ai` and `symfony/ai-decart-platform` packages. No Symfony-specific dependencies are required beyond these.
- How do I configure API keys for Decart in Laravel?
- Store your Decart API key in Laravel’s `.env` file (e.g., `DECART_API_KEY=your_key_here`). The package reads this via Symfony AI’s configuration system, which aligns with Laravel’s environment-based setup. For added security, use `laravel-env-encrypt` to encrypt the key in your config cache.
- Does this support Laravel’s queue system for async AI processing?
- Yes, you can dispatch Decart API calls as Laravel jobs (e.g., `Dispatchable`) to handle them asynchronously. This is useful for batch processing or rate-limit management. Pair it with `spatie/queue-scheduler` to throttle requests and optimize costs.
- What Laravel versions are officially supported?
- The package targets Laravel 10+ (PHP 8.2+) due to Symfony AI’s dependencies. While it may work on older versions, test thoroughly—especially if using Laravel’s newer features like attributes or improved dependency injection. Check Symfony AI’s [requirements](https://github.com/symfony/ai) for exact PHP/Symfony version locks.
- How do I switch between Decart and other AI providers (e.g., OpenAI) in Laravel?
- Symfony AI’s Provider abstraction lets you swap implementations via configuration. Define a `provider` key in your Laravel config (e.g., `ai.providers.default = 'decart'`) and inject the abstract `ClientInterface` into your services. No code changes are needed when switching providers.
- Can I cache Decart API responses in Laravel’s Redis?
- Absolutely. Use Laravel’s `Cache` facade to store Decart responses (e.g., embeddings) with a TTL. Symfony AI’s caching layer integrates with Laravel’s cache drivers, so you can reuse existing Redis/Memcached setups. This reduces API calls and costs significantly.
- What happens if Decart’s API fails or has downtime?
- The package doesn’t include built-in fallback logic, but you can implement it in Laravel. For example, cache responses locally or use a queue retry mechanism (e.g., `failed_jobs` table) to retry failed requests. For critical apps, consider a hybrid approach with a secondary AI provider.
- Are there Laravel-specific testing tools for Decart API interactions?
- Since Decart doesn’t offer a dedicated mock server, use tools like WireMock or Laravel’s HTTP testing helpers to simulate API responses. Mock the `symfony/ai-client` interface in your tests to avoid live calls. For integration tests, use Laravel’s `Http::fake()` to intercept Decart requests.
- How do I handle multi-tenancy with Decart API keys in Laravel?
- Use Laravel’s tenant-aware configuration (e.g., `config('decart.api_key')` with dynamic values) or store keys per tenant in a database table. Libraries like `spatie/laravel-multitenancy` can help manage tenant-specific credentials. Avoid hardcoding keys in shared config files.
- Does this package comply with GDPR/CCPA for AI data processing?
- The package itself doesn’t enforce compliance, but Laravel’s logging and caching systems can be configured to align with regulations. For example, use Laravel’s `Log::channel('single')` with encrypted logs or purge cached AI responses after retention periods. Review Decart’s [platform docs](https://docs.platform.decart.ai/) for their data handling policies.