apie/schema-generator
Generates JSON Schema components from PHP objects with type hints, tailored for Apie entities, value objects, DTOs, enums, lists, and hashmaps. Produces cebe/php-openapi schema objects, focusing on schema sections (not full OpenAPI documents).
components/schemas).zircote/swagger-php or darkaonline/l5-swagger).Illuminate\Validation\Validator) by providing structured schemas.set* methods).components/schemas; missing paths, security, or servers. Requires manual OpenAPI assembly (e.g., using cebe/php-openapi).Apie traits/interfaces (e.g., DtoInterface, StringValueObjectInterface). Custom Laravel models may need adapters.cebe/php-openapi (for schema output), which is already used in some Laravel OpenAPI tools (e.g., darkaonline/l5-swagger).Validator or OpenApi\Generator.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Schema Accuracy | False positives/negatives in generated schemas (e.g., missed Optional attributes). |
Validate against Laravel’s Validator rules or use phpstan for type safety. |
| Performance | Schema generation for large models may be slow. | Cache generated schemas (e.g., Illuminate/Cache) or use Symfony/ComponentCache. |
| Apie Dependency | Tight coupling to Apie traits/interfaces. |
Abstract adapters for Laravel’s native types (e.g., Illuminate\Support\Collection). |
| OpenAPI Gaps | Missing paths, security, or examples. | Combine with cebe/php-openapi or zircote/swagger-php for full spec generation. |
| Backward Compatibility | Monorepo maintenance (PRs to apie-lib-monorepo). |
Pin to specific versions in composer.json and monitor for breaking changes. |
Schema Reuse:
FormRequest rules or Illuminate\Database\Eloquent casts?Customization:
Carbon, Illuminate\Support\Collection) be mapped?ComponentsBuilderFactory or create a Laravel-specific adapter.Tooling Integration:
darkaonline/l5-swagger (OpenAPI generation)?spatie/laravel-fractal (API resource schemas)?CI/CD Impact:
php artisan commands, Git hooks, or deploy)?php artisan apie:generate-schemas command.Long-Term Maintenance:
Illuminate types)?components/schemas for Swagger UI/Redoc.FormRequest rules from schemas.rules() arrays (e.g., using Illuminate/Validation).spatie/laravel-fractal to auto-generate schemas for responses.zircote/swagger-php: More mature but heavier (full OpenAPI generation).darkaonline/l5-swagger: Laravel-specific but less flexible for custom types.openapi: { ... } annotations in FormRequest with auto-generated schemas.Validator.spatie/laravel-fractal.components/schemas with auto-generated ones.ComponentsBuilderFactory and register schemas in the container.// app/Providers/ApieSchemaServiceProvider.php
public function register()
{
$this->app->singleton(ComponentsBuilderFactory::class, function () {
return ComponentsBuilderFactory::createComponentsBuilderFactory();
});
}
| Component | Compatibility Notes |
|---|---|
| Laravel 10/11 | PHP 8.1+ support aligns with Laravel’s requirements. |
| Lumen | Works, but requires manual DI setup (no Laravel Service Container). |
| Illuminate/Validation | Schemas can be converted to rules() arrays (e.g., type: string → `required |
| API Resources | Integrate with spatie/laravel-fractal to transform schemas into API responses. |
| Database (Eloquent) | Schemas can map to migrations or Illuminate\Database\Schema definitions. |
| Testing (Pest/PHPUnit) | Use generated schemas to validate API contracts (e.g., assertJsonSchema). |
composer require apie/schema-generator cebe/php-openapi
ComponentsBuilderFactory.Validator.// app/Console/Commands/GenerateSchemas.php
public function handle()
{
$factory = app(ComponentsBuilderFactory::class);
$schemas = $factory->addCreationSchemaFor(MyDto::class)->getComponents();
file_put_contents(storage_path('app/schemas.json'), json_encode($schemas));
}
phpstan or custom tests).darkaonline/l5-swagger with the generated schemas.Apie traits may break schema generation.Carbon) requires effort.Illuminate types.apie/schema-generator to a minor version in composer.json.How can I help you explore Laravel packages today?