- Can I use answear/speedy-pickup-point-bundle directly in Laravel, or is it Symfony-only?
- While the bundle is Symfony-focused, Laravel integration is possible via two approaches: wrapping Symfony’s HttpKernel or using a standalone Guzzle client. The latter is recommended to avoid Symfony 8’s stricter typing and DI changes. Laravel’s built-in Symfony components may lag behind Symfony 8, so explicit dependency management is required.
- What Laravel versions does this package support?
- The package itself is Symfony-based, but Laravel 8/9/10 can integrate it via facade abstraction or a Guzzle client. Symfony 8’s stricter typing (e.g., Attribute annotations) may require adjustments in Laravel, so test thoroughly. No native Laravel versioning is enforced—compatibility depends on your integration approach.
- How do I configure the Speedy.bg API credentials in Laravel?
- For the Guzzle standalone approach, use Laravel’s `.env` file: `SPEEDY_USERNAME`, `SPEEDY_PASSWORD`, and `SPEEDY_PRIVATE_KEY`. If using Symfony’s HttpKernel, configure via `config/packages/answear.yaml` with `username`, `password`, `language` (e.g., `BG`), and `clientSystemId`. The bundle’s `ConfigProvider` handles validation.
- Will this bundle work in production without caching?
- The Speedy.bg API has latency risks, so caching responses is critical for production. Implement Laravel’s cache drivers (e.g., Redis or file cache) for `FindOffice` or `GetAllPostcodesRequest` responses. Use a TTL of 5–15 minutes to balance freshness and performance, as Speedy.bg may throttle frequent requests.
- Are there alternatives if Symfony 8’s dependency injection breaks my Laravel app?
- Yes. Avoid Symfony 8 entirely by using a standalone Guzzle client (recommended). This bypasses Symfony’s DI system and PSR-15 middleware, reducing Laravel integration risks. Alternatively, abstract the bundle behind a Laravel service layer to isolate Symfony-specific logic.
- How do I handle API errors like rate limits or invalid responses?
- Guzzle 7 (used in the standalone client) provides robust error handling via exceptions like `GuzzleException`. Wrap API calls in try-catch blocks and log errors with Laravel’s `Log` facade. For Symfony’s HttpKernel, use Symfony’s `Problem` component or custom middleware to translate errors into Laravel-friendly responses.
- Can I extend this bundle to support other logistics providers (e.g., DHL, GLS)?
- The bundle is Speedy.bg-specific, but you can abstract the client logic into a Laravel service interface (e.g., `LogisticsClientInterface`). Implement provider-specific adapters (e.g., `SpeedyClient`, `DhlClient`) to swap APIs without changing business logic. This reduces vendor lock-in.
- What’s the best way to test this package in Laravel?
- Mock the Speedy.bg API using Laravel’s `Http` facade or Guzzle’s `MockHandler`. For Symfony’s HttpKernel, use Symfony’s `HttpClient` with a `MockResponse`. Test edge cases like invalid postcodes, rate limits, and authentication failures. Ensure your service layer handles these gracefully.
- Does this bundle support real-time pickup point updates, or is it cached-only?
- The bundle itself doesn’t enforce caching, but Speedy.bg’s API may throttle or block rapid requests. For real-time updates, disable caching and handle API latency with retries or user feedback (e.g., loading spinners). Cache responses for non-critical workflows to improve performance.
- How do I migrate from Symfony’s HttpKernel to a Guzzle client in Laravel?
- Replace Symfony’s `Client` with a Guzzle `HttpClient` in your Laravel service. Update commands (e.g., `FindOffice`) to use Guzzle’s `post()` method instead of Symfony’s `execute()`. Bind the Guzzle client to Laravel’s container via `AppServiceProvider` and test all endpoints. This avoids Symfony 8’s DI changes entirely.