jeandonaldroselin / php-openapi-generator
Jean-Donald Roselin's PHP Openapi Generator - generates PHP API clients from OpenAPI specs and installs them into a Composer project's vendor directory.
Package info
github.com/jeandonaldroselin/php-openapi-generator
pkg:composer/jeandonaldroselin/php-openapi-generator
Requires
- php: >=8.1
- ext-json: *
- symfony/console: ^6.0 || ^7.0
- symfony/filesystem: ^6.0 || ^7.0
- symfony/http-client: ^6.0 || ^7.0
- symfony/process: ^6.0 || ^7.0
- symfony/yaml: ^6.0 || ^7.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Turn an OpenAPI spec into a ready-to-use PHP client, autoloaded straight from your project.
composer require --dev jeandonaldroselin/php-openapi-generator
Quick start
1. Describe your client in openapi-generator.json at your project root:
{
"clients": [
{
"name": "billing",
"input_spec": "https://api.example.com/openapi.yaml",
"package_name": "acme/billing-client",
"additional_properties": {
"invokerPackage": "Acme\\Billing\\Client"
}
}
]
}
2. Generate it:
vendor/bin/generate-client
That's it — the client is generated into .generated/billing/, autoloaded via your project's own
composer.json, ready to use:
use Acme\Billing\Client\Api\InvoicesApi;
Add .generated/ to your project's .gitignore — it's a build artifact regenerated from your
spec(s), not something to commit.
This also registers a post-install-cmd/post-update-cmd script, so any future composer install — a teammate's machine, CI, a Docker build — regenerates the client automatically. A
plain composer install on a completely fresh checkout just works, no manual step needed.
Need several clients? Add more entries to the clients array — one command generates and wires
up all of them. Settings like generator_name, openapi_generator_version,
additional_properties and generated_path can be set once at the root of the file and
overridden per client (see EXPLANATIONS.md).
Options
--config=path.json · --client=name · --generator-version=X · --skip-install ·
--force-download · --force (-f) · --no-scripts
Want to know what happens under the hood (caching, namespace conflicts, project-wide config, etc.)? Everything is explained in EXPLANATIONS.md.