Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
01d3de2
Keep route-cached Skir endpoints working
happyDemon Nov 9, 2026
9b0a840
Render SkirServerException through render() only
happyDemon Nov 9, 2026
1c27e6f
Return Skir errors when the payload does not fit the controller
happyDemon Nov 9, 2026
0704c6a
Accept surrounding backslashes in request_namespace
happyDemon Nov 9, 2026
fd7e505
Drop the duplicate invokable controller stub
happyDemon Nov 9, 2026
a6707ce
Remove the RequestContext compatibility type
happyDemon Nov 9, 2026
6f1609b
Remove unused procedure invocation paths
happyDemon Nov 9, 2026
0fb8079
Remove unread scaffolding members
happyDemon Nov 9, 2026
f12e732
Import exceptions and drop elseif chains
happyDemon Nov 9, 2026
efe6767
Parse PHP for the host version everywhere
happyDemon Nov 9, 2026
f19d721
Stop tracking ignored docs/superpowers
happyDemon Nov 9, 2026
9b5af6d
Remove unreferenced octopus artwork
happyDemon Nov 9, 2026
c9c06f8
Keep development files out of dist archives
happyDemon Nov 9, 2026
9748b6f
Drop the serialization keyword
happyDemon Nov 9, 2026
ad131a8
Remove AGENTS.md reference to a nonexistent root repository
happyDemon Nov 9, 2026
8c7b669
Document endpoint placement, route caching, and hydration errors
happyDemon Nov 9, 2026
6857a01
Update Boost guidance for routing and hydration errors
happyDemon Nov 9, 2026
6102cb5
Tighten the README quick start
happyDemon Nov 9, 2026
b5e8f36
Clarify duplicate-method errors under route caching
happyDemon Nov 9, 2026
6a72521
Merge branch 'main' into cleanup
happyDemon Nov 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/.github export-ignore
/art export-ignore
/docs export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/AGENTS.md export-ignore
/phpunit.xml.dist export-ignore
1 change: 0 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Agent Notes

- Follow the root repository instructions.
- Use `php-guidelines-from-spatie` for PHP changes.
- Keep exceptions package-local under `Skir\Server\Exceptions`.
- Run `vendor/bin/pint --dirty --format agent` after PHP edits.
Expand Down
22 changes: 13 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

Laravel package for exposing SkirRPC methods from a Laravel application.

## Why Skir?
Requires PHP 8.4+, Laravel 13, and Node.js for the Skir compiler.

[Skir](https://skir.build/) is a modern schema language for defining data models and APIs. You describe your structs, enums, and RPC methods once in `.skir` files, then generate clean, idiomatic, and type-safe code across your stack. Skir includes generators for TypeScript, Python, Java, Go, C#, C++, Kotlin, Rust, Swift, and more, while the PHP generators in this ecosystem bring the same schema-first workflow to Laravel. This gives your backend, frontend, and other services a shared source of truth instead of separately maintained DTOs and API contracts.
## Why Skir?

SkirRPC offers many of the same benefits as gRPC—shared method definitions, generated clients and servers, and end-to-end type safety—but runs over standard HTTP requests and integrates with the frameworks you already use. This package brings that workflow to Laravel: generated contracts handle serialization and type information, while your procedures remain ordinary Laravel controllers resolved through the container.
[Skir](https://skir.build/) is a schema language: you define structs, enums, and RPC methods once and generate typed code for PHP, TypeScript, Python, Go, and other languages. This package serves those methods over SkirRPC from ordinary Laravel controllers.

## Features

Expand All @@ -27,7 +27,7 @@ SkirRPC offers many of the same benefits as gRPC—shared method definitions, ge

## Quick start

Install the server package and one PHP generator. This example uses Simple Data Objects:
Install the server package and one PHP generator. This example uses Simple Data Objects; see [Generated procedures](docs/generated-procedures.md) for Laravel Data and standard PHP objects:

```bash
composer require php-skir/server std-out/simple-data-objects
Expand Down Expand Up @@ -68,7 +68,7 @@ generators:
namespace: Skir
```

Skir requires every output directory to end in `/skirout`. It owns that directory and may replace or remove files inside it, so keep handwritten application code elsewhere.
Skir owns the `/skirout` directory and may replace files inside it, so keep handwritten code elsewhere.

Generate the PHP contracts, configure Composer, and refresh the autoloader:

Expand All @@ -90,13 +90,15 @@ The `configure-composer` command reads `skir.yml` and adds this PSR-4 mapping to
}
```

Keep controllers outside `skirout`; the default application-owned namespace is `App\Skir`. Scaffold every generated method and its Form Request with:
Besides the PHP contracts, the generator writes `skir-server-manifest.json` into its `outDir`. `php artisan skir:make` reads the manifests listed in the `skir-server.manifests` config key, which defaults to `app/Skir/skirout/skir-server-manifest.json`, so this layout needs no configuration. Rerun `npx skir gen` (or pass `--generate`) whenever the schema changes.

Scaffold every generated method and its Form Request into the application-owned `App\Skir` namespace with:

```bash
php artisan skir:make --all
```

Generated Form Requests deny access by default; define their `authorize()` and `rules()` methods before exposing the procedure. The command prints the route registrations to add. A module controller has this shape:
Generated Form Requests deny access by default; define their `authorize()` and `rules()` methods before exposing the procedure. Scaffolded controller methods throw a `LogicException` until you implement them. The command prints the route registrations to add. After implementation, a module controller looks like this:

```php
<?php
Expand Down Expand Up @@ -127,18 +129,20 @@ final class AdminController
}
```

Register the controller on a SkirRPC endpoint:
Register the controller on a SkirRPC endpoint in `routes/api.php` (create it with `php artisan install:api` on Laravel 13):

```php
use App\Skir\Admin\AdminController;
use Illuminate\Support\Facades\Route;
use Skir\Server\Facades\Skir;

Route::skirRpc('/api/skir', [
Route::skirRpc('/skir', [
Skir::controller(AdminController::class),
])->studio();
```

The API routes file adds the `/api` prefix, so this endpoint serves `/api/skir`. A POST endpoint in `routes/web.php` fails CSRF verification with HTTP 419 unless its URI is excluded. Class strings, `Skir::controller()`, and `Skir::method()` registrations survive `php artisan route:cache`; provider instances do not. See [Routing](docs/routing.md#route-caching).

Only public controller methods carrying a `SkirMethod` attribute are registered. The generated enum case identifies the Skir method; the PHP method name does not.

The `studio()` call explicitly enables the endpoint-scoped Studio regardless of the configured default. With the default query key, Studio is available at `/api/skir?studio`. See [Routing and Studio](docs/routing.md#studio) for middleware, authorization, and alternative routing layouts.
Expand Down
Binary file removed art/octopus-laravel.png
Binary file not shown.
1 change: 0 additions & 1 deletion art/octopus-laravel.svg

This file was deleted.

1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"laravel",
"php",
"rpc",
"serialization",
"skir"
],
"homepage": "https://github.com/php-skir/server",
Expand Down
2 changes: 1 addition & 1 deletion docs/generated-procedures.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Controller methods can receive the generated DTO directly or receive a Laravel F
2. `fromArray()` for standard PHP objects;
3. `fromSkirValue()` for another compatible application type.

Simple Data Objects and Laravel Data therefore run their generated validation when a decoded object payload is injected directly. Standard PHP objects are hydrated through `fromArray()` and do not add semantic Laravel validation. Use a Form Request when a standard PHP payload needs application validation.
Simple Data Objects and Laravel Data therefore run their generated validation when a decoded object payload is injected directly; a failure returns HTTP 422 `skir_validation_failed` with field errors in `error.details`, the same as a Form Request. Standard PHP objects are hydrated through `fromArray()` and do not add semantic Laravel validation. Use a Form Request when a standard PHP payload needs application validation.

For typed validation, extend `SkirFormRequest` and identify the generated request class:

Expand Down
4 changes: 2 additions & 2 deletions docs/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Failures return a JSON error body with a Skir error code:

| Status | Code | When |
| --- | --- | --- |
| 422 | `skir_invalid_request` | The body is not a valid SkirRPC request, the method name is ambiguous, or the request value does not match the method's request type. |
| 422 | `skir_invalid_request` | The body is not a valid SkirRPC request, the method name is ambiguous, the request value does not match the method's request type, or it cannot be passed to the controller's request parameter. |
| 404 | `skir_method_not_found` | No method with that name or number is registered on the endpoint. |
| 422 | `skir_validation_failed` | A Form Request rejected the decoded input. |
| 422 | `skir_validation_failed` | A Form Request or a validating generated DTO (Laravel Data, Simple Data Objects) rejected the decoded input. |
| 403 | `skir_authorization_failed` | A Form Request's `authorize()` returned `false`. |
| 500 | `skir_invalid_response` | The method returned a value that cannot be serialized as its response type. |

Expand Down
Loading
Loading