Laravel package for consuming SkirRPC services with Saloon.
composer require php-skir/clientPublish the config if you want Laravel container resolution:
php artisan vendor:publish --tag=skir-client-configSKIR_CLIENT_BASE_URL=https://example.com/api/skir
SKIR_CLIENT_ENDPOINT=/
SKIR_CLIENT_CODEC=dense_jsonUse generated MethodDescriptor objects from skir-php-generator or skir-laravel-data-generator:
use App\Skir\Admin\SkirMethods;
use Skir\Client\SkirClient;
$client = new SkirClient('https://example.com/api/skir');
$user = $client->invoke(
SkirMethods::getUser(),
[
'id' => 42,
'name' => 'Maxim',
],
);In Laravel, resolve the configured client from the container:
$user = app(SkirClient::class)->invoke(SkirMethods::getUser(), $payload);Generated typed client adapters wrap this lower-level transport:
use App\Skir\Admin\GetUserRequestData;
use App\Skir\Admin\SkirRpcClient;
use Skir\Client\SkirClient;
$client = new SkirRpcClient(app(SkirClient::class));
$user = $client->getUser(new GetUserRequestData(
userId: 42,
));The package includes an Artisan wrapper for the Skir compiler:
php artisan skir:generate-clientUse skir-php-generator for standard PHP DTOs or skir-laravel-data-generator for Spatie Laravel Data DTOs in your skir.yml.
Example skir.yml for Laravel Data clients:
generators:
- mod: skir-laravel-data-generator
outDir: app/SkirGenerated
config:
namespace: App\SkirThe command runs:
node node_modules/skir/dist/compiler.js gen --root <project-root>Configure the executable paths with:
SKIR_CLIENT_NODE=node
SKIR_CLIENT_SKIR_BIN=/absolute/path/to/node_modules/skir/dist/compiler.js
SKIR_CLIENT_ROOT=/absolute/path/to/projectThe command validates the configured project root and compiler file before spawning Node, then streams compiler output back through Artisan. Typed PHP objects, method descriptors, and typed RPC client adapters are produced by the Skir generator packages configured in skir.yml; this package provides the transport and the Laravel command to run that generation flow.
Dense JSON is the default and matches the default server endpoint:
use App\Skir\Admin\SkirRpcClient;
use Skir\Client\SkirClient;
$transport = new SkirClient('https://example.com', '/api/skir');
$client = new SkirRpcClient($transport);For readable JSON endpoints, configure both sides as standard JSON:
use Skir\Client\Codecs\SkirClientCodecs;
use Skir\Client\SkirClient;
$transport = new SkirClient(
baseUrl: 'https://example.com',
endpoint: '/api/skir',
codec: SkirClientCodecs::standardJson(),
);For base64-encoded dense JSON endpoints:
$transport = new SkirClient(
baseUrl: 'https://example.com',
endpoint: '/api/skir',
codec: SkirClientCodecs::base64DenseJson(),
);For binary CBOR endpoints:
$transport = new SkirClient(
baseUrl: 'https://example.com',
endpoint: '/api/skir',
codec: SkirClientCodecs::cbor(),
);CBOR support is optional. Install spomky-labs/cbor-php in the consuming app before using SkirClientCodecs::cbor() or SKIR_CLIENT_CODEC=cbor.
Container configuration supports:
SKIR_CLIENT_CODEC=dense_json
SKIR_CLIENT_CODEC=standard_json
SKIR_CLIENT_CODEC=base64_dense_json
SKIR_CLIENT_CODEC=cborThe selected client codec must match the server endpoint codec.