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.0.2(2mo ago)38744↓47.6%2[2 PRs](https://github.com/spatie/laravel-openapi-cli/pulls)6MITPHPPHP ^8.4CI passing

Since Feb 11Pushed 2mo 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 1mo ago

READMEChangelog (3)Dependencies (14)Versions (7)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://camo.githubusercontent.com/518f89024f89edc0bbff5d706db55213274a652ff25bbeeea60bc033bbf83922/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d6f70656e6170692d636c692f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-openapi-cli/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/70d096af266d2b3753347db8c7d2cc091abe737d8960704be096f290ad50656e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7370617469652f6c61726176656c2d6f70656e6170692d636c692f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](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')
    ->bearer(env('BOOKSTORE_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,
        };
    });
```

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

50

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.1% 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 ~3 days

Total

4

Last Release

87d 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 (104 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![jimirobaer](https://avatars.githubusercontent.com/u/8984769?v=4)](https://github.com/jimirobaer "jimirobaer (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-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[worksome/envy

Automatically keep your .env files in sync.

6871.8M](/packages/worksome-envy)[spatie/laravel-signal-aware-command

Handle signals in artisan commands

16613.2M2](/packages/spatie-laravel-signal-aware-command)[spatie/laravel-slack-alerts

Send a message to Slack

3212.6M4](/packages/spatie-laravel-slack-alerts)[spatie/laravel-login-link

Quickly login to your local environment

4381.2M1](/packages/spatie-laravel-login-link)

PHPackages © 2026

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