- What Laravel versions does ekyna/dpd support, and how do I check compatibility?
- The package is a PHP component and should work with Laravel 8.0+ since it requires PHP 8.0+. Verify compatibility by checking the package’s `composer.json` for PHP version constraints and testing with your Laravel version in a staging environment. If issues arise, check the GitHub issues for Laravel-specific fixes or create a new one.
- How do I configure the package for production vs. sandbox testing?
- Use Laravel’s `.env` file to define different API endpoints and credentials for sandbox vs. production. The package likely expects configuration via a `config/dpd.php` file (published via `php artisan vendor:publish --tag=dpd-config`). Set `api_endpoint` and `api_key` accordingly, and use environment variables for security.
- Does ekyna/dpd support all DPD API endpoints, or do I need to extend it?
- The package covers core DPD functionalities like label generation, shipment tracking, and pickup/dispatch, but its API coverage may not be exhaustive. Review the [DPD API documentation](https://developer.dpdeurope.com/) and compare it with the package’s examples (e.g., `CreateShipmentWithLabelsBc`). Extend the package by creating a Laravel service layer or using traits to wrap missing endpoints.
- How can I integrate DPD webhooks into my Laravel application if the package doesn’t support them?
- Since the package focuses on API calls, handle DPD webhooks natively in Laravel. Set up a route (e.g., `Route::post('/dpd/webhook', [DpdWebhookController::class, 'handle'])`) to receive DPD’s payloads, validate signatures, and process updates. Use Laravel’s queue system to defer heavy processing and log webhook events for debugging.
- Can I use this package with Laravel’s queue system for high-volume shipments?
- Yes. Dispatch API calls to Laravel’s queue (e.g., `Dpd::generateLabel($shipment)->later()`) to avoid timeouts or rate limits. Configure the queue worker (`php artisan queue:work`) to process DPD requests asynchronously. This also improves performance for bulk operations like generating multiple labels.
- Are there PHPUnit tests included, and how can I adapt them for Laravel?
- The package may include basic unit tests, but they’re likely not Laravel-specific. Adapt them by creating a Laravel test case (e.g., `php artisan make:test DpdTest`) and mocking the DPD client using Laravel’s testing tools like `Http::fake()`. Test critical flows (e.g., label generation, tracking) with DPD’s sandbox API.
- How do I handle errors or rate limits when using this package in production?
- The package may throw exceptions for API failures. Catch these in Laravel’s exception handler (`app/Exceptions/Handler.php`) and log them. For rate limits, implement retry logic using Laravel’s `retry` helper or a package like `spatie/retries`. Monitor API responses and cache frequent queries to reduce load.
- Does ekyna/dpd support multi-country DPD APIs (e.g., Germany vs. UK), or do I need custom logic?
- The package likely supports DPD’s core APIs but may not handle country-specific variations (e.g., DPD Germany vs. UK) out of the box. Check the configuration options for country-specific endpoints. If needed, extend the package by creating country-specific clients or using Laravel’s service container to bind different configurations per country.
- How can I store DPD shipment data in my Laravel database, and what tables should I create?
- Design a `shipments` table with fields like `dpd_tracking_number`, `status`, `created_at`, and foreign keys to Laravel’s `users` or `orders` tables. Use Laravel migrations to create this table and seed it with test data. The package’s API responses (e.g., shipment IDs) can populate these fields during label generation or tracking calls.
- What are some alternatives to ekyna/dpd if I need more features or better Laravel integration?
- Consider `spatie/laravel-dpd` (if available) for a more Laravel-native solution, or build a custom wrapper using Laravel’s HTTP client. For broader carrier support, evaluate packages like `tighten/shipment` or `webkul/shipment`. If the package lacks features, fork it or create a Laravel-specific adapter to extend its functionality.