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

Laravel Openapi Cli Laravel Package

spatie/laravel-openapi-cli

Generate Laravel Artisan commands from an OpenAPI spec. Each API endpoint becomes its own command with typed options for params and request bodies, plus auth, base URL, caching, redirects, and output formatting—ideal for building API CLIs with Laravel Zero.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API-Driven Internal Tools: Eliminates the need for custom CLI scripts or ad-hoc API wrappers by auto-generating Artisan commands from OpenAPI specs. Ideal for teams building tools like data migration scripts, reporting utilities, or automation workflows that interact with APIs.
  • Developer Self-Service: Empowers non-engineers (e.g., QA, support, or data analysts) to interact with APIs via intuitive CLI commands, reducing dependency on backend teams for simple API access.
  • Build vs. Buy Decision: Avoids reinventing CLI tooling for APIs. Instead of building and maintaining custom scripts or SDKs, teams can leverage existing OpenAPI specs to generate CLI commands, saving development time and reducing technical debt.
  • Laravel Zero Ecosystem: Enables the creation of standalone CLI applications (e.g., php artisan myapp:process-invoices) by registering APIs without requiring a full Laravel namespace, expanding use cases for Laravel Zero.
  • API Documentation as Code: Uses OpenAPI specs as a single source of truth for both API documentation and CLI tooling. The auto-generated list command serves as lightweight, interactive documentation for power users.
  • CI/CD Integration: Facilitates API interactions in automated workflows (e.g., triggering deployments, validating data) with proper error handling and retries, improving pipeline reliability.
  • Multi-Tenant or Environment-Specific APIs: Supports dynamic registration of APIs based on environment or tenant, enabling flexible CLI tooling for complex deployments (e.g., tenant1:list, tenant2:list).

When to Consider This Package

  • Adopt if:

    • Your team maintains OpenAPI specs (or can generate them) for APIs you consume or expose, and these specs are up-to-date and comprehensive.
    • You need CLI access to APIs for internal tools, scripts, or Laravel Zero applications, and manual implementation would be time-consuming or error-prone.
    • You want to reduce friction in API adoption by providing self-service access to APIs via CLI commands, especially for non-engineering teams.
    • Your API endpoints have complex parameters (path, query, or request body) that would be cumbersome to manually parse or validate in CLI tools.
    • You’re using Laravel and want to integrate CLI tooling seamlessly with Artisan commands, Laravel Zero, or existing Laravel applications.
    • You need customizable error handling (e.g., retries for rate limits, token refreshes) for API interactions in CLI workflows.
    • You’re looking to modernize legacy scripts that interact with APIs by migrating them to spec-driven, maintainable CLI commands.
  • Look elsewhere if:

    • Your APIs lack OpenAPI specs or the specs are incomplete, outdated, or inconsistent. Without accurate specs, the generated commands may not reflect the actual API behavior.
    • You require GUI tools (e.g., Postman, Insomnia) or SDKs (e.g., generated clients) for API exploration or development, rather than CLI-based access.
    • Your CLI tools need complex logic beyond HTTP requests, such as local file processing, database operations, or advanced data transformations.
    • You’re not using Laravel (though the package can be adapted for non-Laravel PHP projects with additional effort).
    • You prioritize real-time API exploration or interactive testing over scripted, automated access (consider tools like OpenAPI Generator, httpie, or Paw).
    • Your team lacks the resources or expertise to maintain OpenAPI specs or troubleshoot issues with generated CLI commands.

How to Pitch It (Stakeholders)

For Executives:

*"This package transforms our API specifications into reusable, self-service CLI tools—like php artisan api:process-orders --status=pending—without requiring custom development. It’s a game-changer for internal efficiency, cutting the time to build API-driven tools by up to 80%. For example:

  • Support teams can fetch customer data with api:fetch-customer instead of manual API calls.
  • DevOps can trigger deployments via api:deploy --env=staging in CI pipelines.
  • Data teams can automate reports with api:generate-report --format=csv.

It’s like giving our APIs a command-line interface, but auto-generated from the specs we already maintain. This reduces dependency on engineering teams, speeds up tooling development, and ensures consistency across all API interactions."*

Why it matters:

  • Faster innovation: No more waiting for engineers to build CLI wrappers for every API use case.
  • Consistency: Commands are always in sync with the API spec—update the spec, and the CLI updates automatically.
  • Scalability: Add new API endpoints to the CLI by updating the spec, without writing a single line of code.
  • Cost savings: Reduces the need for custom scripts or third-party tools for API access.

For Engineering Teams:

*"This package auto-generates Laravel Artisan commands from OpenAPI specs, so you can expose API endpoints as CLI tools with zero manual work. For example:

  • A POST /users endpoint becomes php artisan api:post-users --input '{"name":"Alice"}'.
  • Path parameters like /books/{id} are converted to --id=123 flags.
  • Query parameters like ?status=active become --status=active.

Key features:

  • Typed parameters: Path, query, and request body parameters are automatically converted to CLI options with validation.
  • Authentication support: Works with Bearer tokens, API keys, OAuth, or custom auth logic via closures.
  • Error handling: Customize responses for HTTP errors (e.g., rate limits, permissions) with hooks like onError and retryOn.
  • Laravel Zero integration: Build standalone CLI apps by registering APIs without namespaces (e.g., php artisan myapp:fetch-data).
  • Caching and performance: Cache API specs and responses to reduce latency in repeated CLI usage.

Use cases:

  • Replace ad-hoc scripts with maintainable, spec-driven commands.
  • Give non-engineers (QA, support, data teams) safe, documented access to APIs.
  • Add CLI endpoints to your Laravel app’s feature set with minimal effort.
  • Integrate API calls into CI/CD pipelines with proper error handling and retries.

Trade-offs:

  • Requires OpenAPI specs (but most modern APIs have them).
  • Best for HTTP-centric workflows; not a replacement for full-fledged SDKs or GUIs.
  • May need customization for APIs with edge cases (e.g., unusual parameter formats)."*

Key Selling Points:

  • "Spec-first development": Commands are generated from OpenAPI specs—update the spec, and the CLI updates automatically.
  • "No more API docs lag": The api:list command serves as interactive documentation for power users.
  • "Laravel-native": Integrates seamlessly with Artisan, Laravel Zero, and Laravel’s HTTP client.
  • "Future-proof": Works with any API that has an OpenAPI spec, including third-party or internal APIs.
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata