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
Schema Generator

Schema Generator Laravel Package

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).

View on GitHub
Deep Wiki
Context7

Composer package of the apie library: schema generator

Frequently asked questions about Schema Generator
How do I generate JSON Schema for Laravel DTOs using apie/schema-generator?
Use `ComponentsBuilderFactory::createComponentsBuilderFactory()` to create a factory, then call `addCreationSchemaFor()` with your DTO class name. This generates a `cebe/php-openapi` schema object for your DTO, which you can integrate into Laravel’s API documentation or validation pipelines.
Does apie/schema-generator work with Laravel’s native types like Carbon or Collections?
Not out of the box—it’s designed for Apie’s abstractions (DTOs, value objects). To support Laravel types, extend `ComponentsBuilderFactory` or create custom adapters mapping `Carbon`, `Collection`, or Eloquent models to Apie-compatible structures.
Can I use this package to auto-generate Laravel FormRequest validation rules?
Yes, but indirectly. Generate schemas first, then parse them to create `rules()` arrays in FormRequests. For example, map `required: true` in schemas to `required` in Laravel’s validation rules, or use a helper library like `spatie/laravel-validation-extensions` for conversion.
What Laravel versions and PHP versions are supported by apie/schema-generator?
The package requires PHP 8.0+ and works seamlessly with Laravel 9, 10, and 11. It has no direct conflicts with Laravel’s core dependencies, but ensure your project’s PHP version aligns with these requirements.
How do I integrate generated schemas with darkaonline/l5-swagger for full OpenAPI docs?
Generate schemas with `apie/schema-generator`, then merge them into `l5-swagger`’s OpenAPI structure. Use `cebe/php-openapi` to combine the components/schemas section with paths, security, or servers defined in `l5-swagger` for a complete spec.
Will this package slow down my Laravel application if I generate schemas on every request?
Yes, schema generation can be resource-intensive. Cache the generated schemas using Laravel’s cache system (e.g., `Illuminate/Cache`) or trigger generation during deployments or via `php artisan` commands to avoid runtime overhead.
Can apie/schema-generator handle nested or recursive DTO structures?
Yes, it supports nested objects and references (`$ref`) automatically. For recursive structures (e.g., self-referencing DTOs), ensure your objects implement Apie’s interfaces like `DtoInterface` and use `$ref` to avoid infinite loops in schema generation.
What’s the difference between apie/schema-generator and spatie/laravel-fractal for API schemas?
apie/schema-generator focuses on generating JSON Schema components from PHP type hints, ideal for validation and OpenAPI/Swagger docs. spatie/laravel-fractal transforms Eloquent models into API resources but lacks deep type-hint integration. Use both for a full pipeline: generate schemas with `apie` and format responses with `fractal`.
How do I test schema generation in a Laravel CI/CD pipeline?
Write unit tests comparing generated schemas to expected outputs using PHPUnit. For integration tests, validate schemas against Laravel’s `Validator` or `l5-swagger`’s OpenAPI parser. Trigger schema generation in CI via a custom `php artisan` command or Git hooks.
Is apie/schema-generator suitable for production use in large-scale Laravel APIs?
Yes, but with caveats. Cache generated schemas aggressively and monitor performance. For critical APIs, combine it with `l5-swagger` or `zircote/swagger-php` to ensure full OpenAPI compliance. Test thoroughly with tools like Postman or Pact for contract validation.
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.
babenkoivan/elastic-client
innmind/static-analysis
innmind/coding-standard
datacore/hub-sdk
alengo/sulu-http-cache-bundle
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity