tuki / http-client-for-laravel
Laravel adapter package for tuki/http-client.
Requires
- php: 7.4.* || 8.*
- ext-curl: *
- ext-json: *
- laravel/framework: ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0
- tuki/http-client: ^1.0.3
Requires (Dev)
- nunomaduro/larastan: ^1.0
- orchestra/testbench: >=6.0
- phpstan/phpstan: ^1.12
- phpunit/phpunit: >=9.5 <12.0
README
Laravel integration layer for tuki/http-client. Adds auto-discovery, a facade, database persistence, async sink dispatch, framework events, and first-class test support — all wired to the Laravel container.
Profiles can also define reusable authentication through seal providers, so a bearer token or HTTP Basic setup lives in config and is applied automatically to every request sent through that profile.
Requirements
- PHP:
7.4.* || 8.* - Laravel:
>= 8.0 - PHP extensions:
ext-curl,ext-json - Core dependency:
tuki/http-client:^1.0
Installation
composer require tuki/http-client-for-laravel
Publish config and migrations, then migrate:
php artisan vendor:publish --provider="Tuki\HttpClientForLaravel\TukiHttpClientForLaravelServiceProvider" --tag=config
php artisan vendor:publish --provider="Tuki\HttpClientForLaravel\TukiHttpClientForLaravelServiceProvider" --tag=migrations
php artisan migrate
Define your first profile in config/tuki_http_client.php:
'default_profile' => 'pokemon_api',
'profiles' => [
'pokemon_api' => [
'base_uri' => 'https://pokeapi.co/api/v2',
'timeout' => 20,
'connect_timeout' => 10,
],
],
Send a request via the facade:
use Tuki\HttpClientForLaravel\Facades\HttpClient;
$response = HttpClient::newRequest('pokemon.search')
->to('GET', '/pokemon/pikachu')
->expectsJson()
->execute();
$payload = $response->getJsonData();
→ For a complete setup walkthrough, see Installation and first success.
Documentation
- Documentation index
- Installation and first success
- Using the client
- Configuration and profiles
- Authentication and seal providers
- Sinks and dispatch modes
- Persistence and pruning
- Events and Guzzle interception
- Testing
- Migration and adoption
- Troubleshooting
- Contributing
License
MIT. See LICENSE.
Validation
composer test
composer stan
composer coverage
From the workspace root, the recommended execution path is the root Makefile:
make laravel-qa
make laravel-coverage
Inside this package, use Makefile targets directly. They support both local Docker and CI/direct execution:
make qa # local default: Docker mode
make qa USE_DOCKER=0 # CI/direct mode (no docker compose wrapper)