Laravel package for calling SkirRPC services through generated typed clients and Saloon.
- Generate typed RPC clients from Skir schemas with the client generation guide.
- Use standard PHP objects, Laravel Data, or Simple Data Objects.
- Configure Laravel container resolution and matching wire codecs with the configuration and codecs guide.
- Handle failures and test without network requests.
Install the client and standard PHP generator:
composer require php-skir/client
npm install --save-dev skir skir-php-generatorCreate 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: SkirSkir 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
npx skir-php-generator configure-composer
composer dump-autoload
php artisan vendor:publish --tag=skir-client-configConfigure the server endpoint and matching wire codec:
SKIR_CLIENT_BASE_URL=https://api.example.test
SKIR_CLIENT_ENDPOINT=/api/skir
SKIR_CLIENT_CODEC=dense_jsonCall 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;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.
