HttpClient facade) and PSR-7 middleware stack (e.g., Illuminate\Http\Middleware).Http client (v1.x) is not PSR-18 compliant, requiring explicit Guzzle integration or upgrades to Laravel 10+ (PSR-18 support).Yang\Decorator) simplify complex API interactions.page[number], page[size]) and sparse fieldsets reduces frontend complexity.422 Unprocessable Entity) maps directly to Laravel’s ValidationException, easing error handling.guzzlehttp/guzzle (PSR-7) or symfony/http-client (PSR-18) if Laravel’s HTTP client is used.composer.json or use Laravel’s HttpClient with a PSR-7 adapter (e.g., php-http/guzzle7-adapter).Cache facade).Collection macros or custom hydrators.yang/oauth2 would need evaluation).VentureCraft/revel or mockery for PSR-7 messages.)Http client (v1.x) without PSR-7 adapters.ApiResource) for server-side rendering.UserService) with Yang:
use Woohoolabs\Yang\Client;
use Woohoolabs\Yang\Decorator\PaginationDecorator;
$client = new Client('https://api.example.com', [
'auth' => ['token' => '...'],
]);
$decorated = new PaginationDecorator($client);
$users = $decorated->get('/users')->json();
get()/find() methods.create()/update().// app/Facades/ApiClient.php
class ApiClient extends \Illuminate\Support\Facades\Facade {
protected static function getFacadeAccessor() {
return 'yang.client';
}
}
AppServiceProvider:
$this->app->singleton('yang.client', function () {
return new Client(config('services.api.url'), [
'auth' => ['token' => config('services.api.token')],
]);
});
Yang\Middleware\JsonApiErrorHandler).php artisan vendor:publish.Container).php-http/guzzle7-adapter if stuck on v9.guzzlehttp/guzzle (PSR-7) or symfony/http-client (PSR-18) is installed.Http::get() with Yang’s Client::get() for critical paths.PaginationDecorator) and relationships (RelationshipDecorator).Http tests or PestPHP.$client = new Client('https://api.example.com', [
'handler' => HandlerStack::create([
new \GuzzleHttp\Middleware::tap(function ($request) {
\Log::debug('Request:', ['url' => $request->getUri()]);
}),
]),
]);
dd() or dump() for Yang responses to verify payloads.Yang\Exception\JsonApiException for custom error mapping:
try {
$client->delete('/users/1');
} catch (JsonApiException $e) {
if ($e->getStatusCode() === 404) {
abort(404, 'User not found');
}
}
Cache facade for frequent API calls with Cache::remember().Pool for parallel requests.How can I help you explore Laravel packages today?