php-openapi/openapi
PHP library for reading, validating, and writing OpenAPI 3.0 specifications. Parse JSON or YAML into an object model, resolve references, inspect paths and schemas, and generate updated spec files—useful for API tooling, docs, and governance.
$ref resolution, and schema validation, this replaces that work with an MIT-licensed dependency. The build cost we avoid is not the parser itself but the long tail: multi-file $ref graphs, 3.0 vs 3.1 drift, and schema validation edge cases.Consider it when:
$ref resolution across multi-file specs, which is where naive json_decode approaches break down.openapi-generator, swagger-cli) from our build scripts — fewer runtimes in the pipeline is a real operational win.Look elsewhere when:
cebe/php-openapi) has substantially more community traction; evaluate whether we should depend on that package directly, or treat this as a fork whose divergence we would have to own.openapi-generator has broader language and template coverage than anything we would assemble on top of a parser.To executives: We can make the API specification the authoritative contract for our PHP services rather than documentation that drifts from reality. This is an MIT-licensed library, so cost of adoption is engineering time, not licensing. It unblocks three roadmap items at once: automated contract checks in CI, generated client SDKs, and generated developer documentation. The strategic value is reduced integration breakage and less manual API bookkeeping — the risk to manage is dependency health, which we address with a short evaluation spike and an internal wrapper so we are not locked in.
To engineering: php-openapi/openapi gives us a proper OpenAPI 3.0/3.1 object model in PHP — parse, inspect, mutate, validate, serialize, with $ref resolution for multi-file specs. It fits natively into our Laravel build and CI tooling without adding a Node or Java runtime to the pipeline. Two caveats to plan around: (1) the repository's visible adoption is low, so we should pin a version, run a spike against our real spec corpus, and check the issue tracker and release cadence before committing; (2) we should wrap it behind a thin internal adapter interface so a swap — to the upstream package or to a different parser — is a one-file change rather than a refactor. If the spike passes, this is a small, well-scoped dependency that removes a genuinely annoying category of bespoke code.
How can I help you explore Laravel packages today?