Skip to content

Installation

RequirementVersion
PHP8.2 or newer (8.3 or newer on Laravel 13)
Laravel11, 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.

  1. Require spatie/laravel-data as a runtime dependency.

    Terminal window
    composer require spatie/laravel-data:^4.23

    The generated classes extend Spatie\LaravelData\Data and 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.

  2. Require the generator as a dev dependency.

    Terminal window
    composer require --dev codewithagents/openapi-laravel

    The 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-data at runtime.

  3. Publish the config file (optional).

    Terminal window
    php artisan vendor:publish --tag=openapi-laravel-config

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