PHPackages                             spatie/laravel-openapi-cli - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. spatie/laravel-openapi-cli

ActiveLibrary[CLI &amp; Console](/categories/cli)

spatie/laravel-openapi-cli
==========================

Create a Laravel command for your OpenAPI spec(s). Works in apps and other packages. Useful for AI agents.

1.3.1(1w ago)391.5k↓74.5%4[1 PRs](https://github.com/spatie/laravel-openapi-cli/pulls)6MITPHPPHP ^8.4CI failing

Since Feb 11Pushed 1w ago1 watchersCompare

[ Source](https://github.com/spatie/laravel-openapi-cli)[ Packagist](https://packagist.org/packages/spatie/laravel-openapi-cli)[ Docs](https://github.com/spatie/laravel-openapi-cli)[ GitHub Sponsors](https://github.com/Spatie)[ RSS](/packages/spatie-laravel-openapi-cli/feed)WikiDiscussions main Synced today

READMEChangelog (8)Dependencies (42)Versions (12)Used By (6)

 [   ![Logo for Laravel OpenAPI CLI](https://camo.githubusercontent.com/ec05ecf6ee8f2d16a6bf6ab8aa19293e69b05b3b7a7507b16735849d41417329/68747470733a2f2f7370617469652e62652f7061636b616765732f6865616465722f6c61726176656c2d6f70656e6170692d636c692f68746d6c2f6c696768742e776562703f3132333435)  ](https://spatie.be/open-source?utm_source=github&utm_medium=banner&utm_campaign=laravel-openapi-cli)Create Laravel commands for your OpenAPI specs
==============================================

[](#create-laravel-commands-for-your-openapi-specs)

[![Latest Version on Packagist](https://camo.githubusercontent.com/594072bc3c36300812e95620aae0f3b7d5f8240202999e2eecbe410ba5bd2fbd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d6f70656e6170692d636c692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-openapi-cli)[![GitHub Tests Action Status](https://github.com/spatie/laravel-openapi-cli/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-openapi-cli/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://github.com/spatie/laravel-openapi-cli/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/spatie/laravel-openapi-cli/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/3e7251930e05bca9c1a293c9dcdf726f7467f447ec7dabbd32d3f65fcad52605/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6f70656e6170692d636c692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-openapi-cli)

Turn any OpenAPI spec into dedicated Laravel artisan commands. Each endpoint gets its own command with typed options for path parameters, query parameters, and request bodies. Combined with [Laravel Zero](https://laravel-zero.com), this is a great way to build standalone CLI tools for any API that has an OpenAPI spec.

```
use Spatie\OpenApiCli\Facades\OpenApiCli;

OpenApiCli::register('https://api.bookstore.io/openapi.yaml', 'bookstore')
    ->baseUrl('https://api.bookstore.io')
    ->auth(fn () => app(OAuthTokenManager::class)->token())
    ->banner('Bookstore API v2')
    ->cache(ttl: 600)
    ->followRedirects()
    ->yamlOutput()
    ->showHtmlBody()
    ->useOperationIds()
    ->onError(function (Response $response, Command $command) {
        return match ($response->status()) {
            429 => $command->warn('Rate limited. Retry after '.$response->header('Retry-After').'s.'),
            default => false,
        };
    })
    ->retryOn(function (Response $response, Command $command) {
        if ($response->status() !== 401) {
            return false;
        }

        return app(OAuthTokenManager::class)->refresh();
    }, maxRetries: 1);
```

For a spec with `GET /books`, `POST /books`, `GET /books/{book_id}/reviews`, and `DELETE /books/{book_id}`, you get these commands:

- `bookstore:get-books`
- `bookstore:post-books`
- `bookstore:get-books-reviews`
- `bookstore:delete-books`
- `bookstore:list`

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/371f8e7030af2ffe6de787c7ffdbe807e81e3a83763c2361ef511769a8d5c537/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6f70656e6170692d636c692e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-openapi-cli)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Documentation
-------------

[](#documentation)

All documentation is available [on our documentation site](https://spatie.be/docs/laravel-openapi-cli).

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Alex Vanderbist](https://github.com/AlexVanderbist)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

56

—

FairBetter than 97% of packages

Maintenance98

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community25

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 79.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~19 days

Recently: every ~31 days

Total

8

Last Release

7d ago

Major Versions

0.0.1 → 1.0.02026-02-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (106 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (19 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![enricodelazzari](https://avatars.githubusercontent.com/u/10452445?v=4)](https://github.com/enricodelazzari "enricodelazzari (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (1 commits)")[![zupolgec](https://avatars.githubusercontent.com/u/161318?v=4)](https://github.com/zupolgec "zupolgec (1 commits)")

---

Tags

aiapiclilaravelopenapiphpspecsspatielaravellaravel-openapi-cli

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/spatie-laravel-openapi-cli/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-laravel-openapi-cli/health.svg)](https://phpackages.com/packages/spatie-laravel-openapi-cli)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
