Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Cebe Php Openapi

Cebe Php Openapi Laravel Package

devizzent/cebe-php-openapi

Fork of cebe/php-openapi providing PHP objects to read/write OpenAPI 3.0/3.1 YAML and JSON. Includes a CLI tool to validate and convert API description files. Install via Composer; works on PHP 7.1+ (including PHP 8).

View on GitHub
Deep Wiki
Context7

Read and write OpenAPI yaml/json files and make the content accessible in PHP objects.

Frequently asked questions about Cebe Php Openapi
How do I install this package in a Laravel project?
Run `composer require devizzent/cebe-php-openapi` in your project root. The package supports PHP 7.1+ and integrates seamlessly with Laravel’s Symfony-based components. No additional Laravel-specific setup is required beyond Composer installation.
Does this package support OpenAPI 3.1 features like JSON Schema 2020-12?
Yes, this fork explicitly adds OpenAPI 3.1 support, including JSON Schema 2020-12. The package validates against both 3.0.x and 3.1.x schemas, making it future-proof for newer API specifications. Test coverage includes regression checks for both versions.
Can I use the CLI tool to validate OpenAPI specs in Laravel’s CI pipeline?
Absolutely. The `php-openapi validate` command exits with non-zero status on errors (2 for schema violations, 1 for parsing issues), making it ideal for CI/CD pipelines. Integrate it via `vendor/bin/php-openapi validate api-spec.yaml` in your build script.
Will this work with Laravel 10/11 and Symfony YAML 8.x?
Yes, the package is explicitly compatible with Symfony YAML 8.x, aligning with Laravel 10/11’s Symfony 6.4+ stack. However, verify your `composer.json` constraints—some projects may still need `symfony/yaml:^6.0` to avoid conflicts with Laravel’s dependencies.
How do I load an OpenAPI spec from a Laravel config file (e.g., `config/openapi.yaml`)?
Use Symfony’s YAML parser (included via this package) to load the file: `$yaml = file_get_contents(config_path('openapi.yaml')); $openapi = OpenApi::parse($yaml)`. For cached specs, store the parsed object in Laravel’s cache: `Cache::remember('openapi-spec', 3600, fn() => OpenApi::parse(...));`.
Are there performance concerns when parsing large OpenAPI specs (e.g., 500+ endpoints)?
Parsing performance remains unchanged from the original library, but Symfony YAML 8.x may introduce minor overhead. Mitigate this by caching parsed objects (e.g., `Cache::forever()`) or benchmarking with your specific spec size. The CLI tool avoids PHP overhead for repeated validations.
Can I extend OpenAPI schemas with custom Laravel-specific annotations?
Yes, leverage Symfony’s YAML tags to add custom annotations. For example, define a `laravel:auth` tag in your YAML and extend the parser to handle it. The package’s object model allows deep customization of schema components without modifying core functionality.
What alternatives exist for OpenAPI validation in Laravel?
Alternatives include Symfony’s `openapi` component (tightly integrated with this package) and `zircote/swagger-php` (legacy support). This fork stands out for its active OpenAPI 3.1 support and Symfony YAML 8 compatibility, which aligns better with modern Laravel stacks.
How do I test this package in a Laravel unit test?
Mock the `OpenApi` class or use real specs from `tests/OpenApi` (included in the package). Example: `$spec = OpenApi::parse(file_get_contents(__DIR__.'/spec.yaml')); $this->assertInstanceOf(OpenApi::class, $spec);`. For schema validation, assert CLI exit codes via `Artisan::call('php-openapi validate', ['input' => 'spec.yaml'])`.
Does this package work with Lumen or other lightweight Laravel frameworks?
Yes, the package is framework-agnostic and works in Lumen, Laravel, or standalone PHP. Lumen projects benefit from Symfony YAML 8 compatibility (e.g., for config-based API specs) without requiring full Laravel dependencies. Use the same installation and CLI commands as in Laravel.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
andydefer/laravel-cluster
aimeos/ai-admin-mcp
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor