Installation
Requirements
Section titled “Requirements”| Requirement | Version |
|---|---|
| PHP | 8.2 or newer (8.3 or newer on Laravel 13) |
| Laravel | 11, 12, or 13 (for the artisan command) |
| spatie/laravel-data | ^4.23, a runtime dependency of your app: composer require spatie/laravel-data:^4.23 |
spatie/laravel-data v4 is a runtime peer dependency, not a dev dependency: the generated classes extend Spatie\LaravelData\Data, so your app loads it at runtime. The standalone binary runs without Laravel, so a Laravel install is only required for the artisan command and the published config file.
Supported platforms are Linux and macOS. The generator’s path handling is POSIX-style and Windows is not covered by CI, so Windows is unsupported.
Install
Section titled “Install”-
Require
spatie/laravel-dataas a runtime dependency.Terminal window composer require spatie/laravel-data:^4.23The generated classes extend
Spatie\LaravelData\Dataand use its attributes (#[MapName],#[DataCollectionOf]), so this is a normal runtime dependency of your app, not a dev dependency. Without it, a fresh app hits fatal autoload errors the moment it loads a generated class. -
Require the generator as a dev dependency.
Terminal window composer require --dev codewithagents/openapi-laravelThe generator runs at build time, so it is a dev dependency. The classes it emits are committed to your repo and depend only on
spatie/laravel-dataat runtime. -
Publish the config file (optional).
Terminal window php artisan vendor:publish --tag=openapi-laravel-configThis writes
config/openapi-laravel.php, where you can set the spec path, output path and namespace, and other options. See the configuration reference.
Head to the quick start to generate your first Data classes.