answear/inpost-pickup-point-bundle
FindPoints) and request-builder (FindPointsRequestBuilder) align well with Laravel’s service-oriented architecture. It can be encapsulated as a Laravel service without tight coupling to Symfony’s Bundle structure.PointFunctionsType enums) enables phased rollouts for EU markets.services.yaml with Laravel’s bindings in AppServiceProvider:
$this->app->bind(
Answear\InpostBundle\Request\FindPointsInterface::class,
Answear\InpostBundle\Request\FindPoints::class
);
Command to Laravel’s Artisan command:
Artisan::command('inpost:find-points', function () {
$request = (new FindPointsRequestBuilder())->setPostCode('00-001')->build();
$response = app(FindPointsInterface::class)->findPoints($request);
// Output or process response
});
Http::client()) to avoid Symfony’s HttpClient dependency.PointType, PointFunctionsType), so no additional abstraction is needed.config/packages/answear_inpost.yaml with Laravel’s .env and config files:
INPOST_API_KEY=your_key
INPOST_BASE_URI=https://api.inpost.pl
symfony/serializer and symfony/property-info, which may not be used elsewhere. Mitigation: Use standalone Composer packages (e.g., symfony/serializer without the full Symfony bundle).Http::fake() to mock API responses.try-catch and log errors via Log::error().InpostApiException).FindPointsJob with shouldQueue()).Cache::remember()).Http::client() or GuzzleHttp\Client).symfony/serializer if needed for response parsing) or replaced with Laravel equivalents (e.g., spatie/array-to-object for deserialization).Command class.pickup_points) for offline use.InpostService) that:
FindPointsRequestBuilder to Laravel’s DI.HttpClient with Laravel’s Http::client().findPointsByPostcode(string $postcode): array.namespace App\Services;
use Answear\InpostBundle\Request\FindPointsRequestBuilder;
use Illuminate\Support\Facades\Http;
class InpostService {
public function findPoints(string $postcode): array {
$request = (new FindPointsRequestBuilder())->setPostCode($postcode)->build();
$response = Http::withHeaders([
'Authorization' => config('inpost.api_key'),
])->post(config('inpost.api_endpoint'), $request->toArray());
return $response->json();
}
}
config/services.php:
'inpost' => [
'api_key' => env('INPOST_API_KEY'),
'api_endpoint' => 'https://api.inpost.pl/shipx/v1/points',
'cache_ttl' => env('INPOST_CACHE_TTL', 3600), // 1 hour
],
InpostService to cache responses:
public function findPoints(string $postcode): array {
return Cache::remember(
"inpost_points_{$postcode}",
config('inpost.cache_ttl'),
fn() => $this->fetchFromApi($postcode)
);
}
Artisan::command('inpost:search {postcode}', function ($postcode) {
$points = app(InpostService::class)->findPoints($postcode);
dd($points);
});
Route::get('/api/pickup-points', function (Request $request) {
return app(InpostService::class)->findPoints($request->postcode);
});
// Example: Fetch points on postcode input
document.getElement
How can I help you explore Laravel packages today?