php-skir / client
Laravel SkirRPC client package powered by Saloon.
Requires
- php: ^8.3
- illuminate/console: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
- php-skir/runtime: ^0.2@dev
- saloonphp/saloon: ^4.0
- symfony/process: ^6.4|^7.0|^8.0
Requires (Dev)
- laravel/pint: ^1.29
- orchestra/testbench: ^10.0|^11.0
- phpunit/phpunit: ^11.5|^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-11 14:24:46 UTC
README
Laravel Skir Client
Call SkirRPC services from Laravel through generated, typed PHP clients. Requests go out over Saloon using the standard SkirRPC protocol, so the server can be php-skir/server or a Skir service written in any other language.
Requirements: PHP 8.3+, Laravel 12 or 13, and Node.js for the Skir compiler.
Features
- Generate typed RPC clients from Skir schemas with the client generation guide.
- Use standard PHP objects, Laravel Data, or Simple Data Objects.
- Configure the server URL, endpoint, and authentication with the configuration guide.
- Handle failures and test without network requests.
Quick start
Install the client and standard PHP generator:
composer require php-skir/client npm install --save-dev skir skir-php-generator
Create skir-src/admin/users.skir:
struct GetUserRequest {
user_id: int32;
}
struct User {
user_id: int32;
name: string;
}
method GetUser(GetUserRequest): User = 3180856469;
Configure the root skir.yml:
generators: - mod: skir-php-generator outDir: skir/skirout config: namespace: Skir
Skir owns the output directory and may replace its contents during generation.
Generate the client, configure Composer autoloading, and publish the Laravel config:
npx skir gen # or: php artisan skir:generate-client
npx skir-php-generator configure-composer
composer dump-autoload
php artisan vendor:publish --tag=skir-client-config
Configure the server endpoint:
SKIR_CLIENT_BASE_URL=https://api.example.test SKIR_CLIENT_ENDPOINT=/api/skir
If the server expects a credential, configure it in the same file. For example, to send a shared secret in a custom header:
SKIR_CLIENT_AUTH_TYPE=header SKIR_CLIENT_AUTH_HEADER=X-Internal-Token SKIR_CLIENT_AUTH_TOKEN=your-shared-secret
Every request then carries X-Internal-Token: your-shared-secret. Bearer, basic, and custom authentication are covered in the configuration guide.
Call the service through the generated typed client:
use Skir\Admin\GetUserRequest; use Skir\Admin\SkirRpcClient; use Skir\Client\SkirClient as TransportSkirClient; $client = new SkirRpcClient(app(TransportSkirClient::class)); $user = $client->getUser(new GetUserRequest(userId: 42)); echo $user->name;
Generator alternatives
Standard PHP is the dependency-light baseline. Use skir-laravel-data-generator for Laravel Data or skir-simple-data-objects-generator for Simple Data Objects.
