- Can I use this package directly in Laravel, or is it only for Symfony?
- While the package is a Symfony bundle, Laravel can leverage its core logic by extracting standalone classes like `Command`, `Request`, and `Enum` into a Laravel service provider. Symfony-specific components (e.g., bundles, dependency injection) can be bypassed or adapted.
- What Laravel versions does this package support?
- The package relies on PHP 8.2+ features (e.g., enums) and targets Laravel 10/11 for full compatibility. Older Laravel versions may require manual adjustments or polyfills for type safety and dependency injection.
- How do I configure API credentials securely in Laravel?
- Replace the Symfony YAML config (`answear_mwl.yaml`) with Laravel’s `config/mwl.php`, storing `partnerKey` and `secretKey` in environment variables (e.g., `.env`). Use Laravel’s `env()` helper or a vault service for production-grade security.
- Does this package handle API rate limiting or retries?
- The package does not include built-in rate limiting or retry logic. You’ll need to extend Laravel’s `HttpClient` with middleware or use decorators to handle throttling, timeouts, or exponential backoff for production resilience.
- How do I map API responses to Laravel Eloquent models?
- The package returns raw API data (e.g., pickup points, cities). Use Laravel’s `Resource` classes or DTOs to transform responses into Eloquent models. For example, create a `PickupPointResource` to map JSON fields to a `PickupPoint` model.
- Is there a way to cache API responses for better performance?
- The package lacks caching abstractions, but you can wrap API calls in Laravel’s `Cache::remember()` or use `HttpClient` caching middleware. For high-volume requests, cache responses by carrier/country code with a TTL (e.g., 5 minutes).
- What if the MWL API changes or deprecates endpoints?
- The package’s last release (2026-06-22) aligns with the Postman docs (2021), but API changes could break compatibility. Monitor the [MWL API documentation](https://documenter.getpostman.com/view/12823986/TzCTam5v) and extend the package’s `Request` classes to adapt to new endpoints or schemas.
- How do I test this package in Laravel without hitting the real API?
- Use Laravel’s `HttpClient` mocking or Pest’s `mock()` to simulate API responses. For example, mock `GetPickupPointsCommand` in a test to return hardcoded data, then assert the parsed output matches your Eloquent models or DTOs.
- Are there alternatives for Ukrainian carrier integrations in Laravel?
- Alternatives include building a custom Laravel service using Guzzle or Nova Poshta’s official SDK, or exploring packages like `spatie/laravel-http-client` for generic API integrations. This bundle is niche but optimized for MWL’s specific pickup point logic.
- How do I integrate this package into an existing Laravel project with minimal coupling?
- Start by adding the package as a `require-dev` dependency, then extract the core classes (e.g., `Command`, `Request`) into a Laravel service provider. Replace Symfony’s `ConfigProvider` with Laravel’s config system and use dependency injection to swap Guzzle for Laravel’s `HttpClient` if needed.