Download the PHP package fissible/forge without Composer
On this page you can find all versions of the php package fissible/forge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fissible/forge
More information about fissible/forge
Files in fissible/forge
Package forge
Short Description OpenAPI spec generation for PHP — scaffolds specs from routes and infers schemas from validation rules
License MIT
Homepage https://github.com/fissible/forge
Informations about the package forge
fissible/forge
OpenAPI spec generation for PHP. Scaffolds a valid OpenAPI 3.0 spec from your application's routes, inferring request body schemas from Laravel FormRequest validation rules.
Part of the Fissible suite. Depends on: fissible/accord and fissible/drift (uses route inspection and spec source interfaces).
Why spec generation helps
Writing an OpenAPI spec by hand for an existing API is tedious and easy to get wrong. Every route needs a path entry, every request body needs a schema, and any mistake means the spec diverges from reality before it's even been published.
forge does the mechanical work for you. It reads the routes your application already defines, inspects any FormRequest classes to understand what each endpoint expects, and produces a valid, structured OpenAPI 3.0 spec as a starting point. You fill in the response schemas; forge handles everything else.
The output is a real spec — one you can commit, version, and hand to fissible/accord for validation, or share with API consumers and tooling that understands OpenAPI.
Requirements
- PHP ^8.2
- fissible/accord ^1.0
- fissible/drift ^1.0
Installation
Laravel auto-discovery
The service provider registers automatically. The generate command is registered with Artisan:
How it works
Forge enumerates your routes, groups them by path, and builds an OpenAPI operation for each. For POST, PUT, and PATCH routes, it inspects the controller action signature to find any FormRequest class, calls rules() on it, and converts those rules to a JSON Schema object for the requestBody.
Response schemas are scaffolded as empty objects ({}) — these are intentionally left for you to fill in, since response structure can't be reliably inferred from routes alone.
Console command
accord:generate
Generates a spec file from your API routes:
| Option | Default | Description |
|---|---|---|
--version |
v1 |
URI version to generate for (filters routes matching /v1/...) |
--title |
API |
Value for info.title in the spec |
--output |
resources/openapi/{version}.yaml |
Output file path |
--force |
— | Overwrite an existing spec file |
The generated file is ready to commit and compatible with fissible/accord for runtime validation.
Schema inference
Forge maps Laravel validation rules to JSON Schema properties:
| Rule | Schema effect |
|---|---|
integer, int, numeric |
type: integer |
boolean, bool, accepted, declined |
type: boolean |
array |
type: array |
number, decimal |
type: number |
string (default) |
type: string |
email |
format: email |
url |
format: uri |
date |
format: date |
date_format:* |
format: date-time |
uuid |
format: uuid |
nullable |
nullable: true |
min:N |
minLength (string) or minimum (numeric) |
max:N |
maxLength (string) or maximum (numeric) |
in:a,b,c |
enum: [a, b, c] |
digits:N |
minLength: N, maxLength: N |
required |
field added to required array |
Rule objects (e.g. Rule::in([...])) are skipped — add those schema details manually after generation.
Dot-notation nested fields (e.g. address.city) are currently skipped. The parent field (address) is included with type: array.
Example output
Given a POST /v1/users route with this FormRequest:
Forge generates:
Laravel
FormRequest inspector
The bundled LaravelFormRequestInspector reflects controller action signatures to find FormRequest subclasses:
It handles any controller action of the form ControllerClass@method. Closure-based routes are skipped. The inspector uses ReflectionClass::newInstanceWithoutConstructor() to call rules() without triggering Laravel's request validation lifecycle — this means FormRequests with required fields work correctly during spec generation, even outside of an HTTP request context. If rules() itself cannot run without a real request (e.g. because it reads $this->route()), it falls back to an empty object schema.
Custom inspectors
Implement FormRequestInspectorInterface to extract validation rules from any source:
Bind it in your service provider before ForgeServiceProvider loads, or override it after:
Core API
Use forge programmatically without the console command:
Recommended workflow
- Generate a spec from your existing routes with
accord:generate - Fill in the response schemas in the generated YAML
- Commit the spec to version control
- Validate requests and responses at runtime with fissible/accord
- Detect drift as your API evolves with fissible/drift
License
MIT
All versions of forge with dependencies
fissible/accord Version ^1.0
fissible/drift Version ^1.0
symfony/console Version ^6.0|^7.0
symfony/yaml Version ^6.0|^7.0