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 by auto-generating Artisan commands from OpenAPI specs, reducing technical debt for internal workflows (e.g., data migration, reporting, or automation).
  • 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 calls.
  • Laravel Zero Ecosystem: Enables rapid development of standalone CLI tools (e.g., php artisan invoice-processor:generate) by leveraging OpenAPI specs as a single source of truth for API endpoints.
  • API Documentation as Code: Uses OpenAPI specs to generate interactive CLI documentation (via the list command), ensuring docs stay in sync with the API and are always executable.
  • CI/CD Integration: Embeds API calls into pipelines (e.g., php artisan api:trigger-build --env=prod) with built-in retry logic for transient failures (e.g., OAuth token refresh).
  • Multi-Environment Support: Dynamically register APIs per environment (e.g., dev:, staging:, prod:) using environment-specific OpenAPI specs or base URLs.
  • Legacy Modernization: Replaces outdated PHP scripts or ad-hoc curl commands with maintainable, typed CLI tools backed by OpenAPI specs.
  • AI/ML Pipeline Integration: Useful for AI agents or data pipelines that need to programmatically invoke APIs with structured inputs/outputs (e.g., feature extraction, model training).

When to Consider This Package

Adopt if:

  • Your OpenAPI specs are up-to-date and cover the APIs you need to interact with (or you’re willing to generate/maintain them).
  • You’re building CLI tools, scripts, or Laravel Zero apps that interact with APIs, and you want to avoid manual command parsing.
  • You need self-documenting API access for internal teams (e.g., QA, support) without exposing a full GUI.
  • Your API has complex parameters (path, query, or body) that would be error-prone to manually handle in CLI tools.
  • You’re using Laravel and want to integrate seamlessly with Artisan, Laravel Zero, or existing Laravel services (e.g., auth managers).
  • You need retry logic for transient failures (e.g., rate limits, expired tokens) without writing custom middleware.

Look elsewhere if:

  • Your APIs lack OpenAPI specs (or specs are incomplete/outdated). Consider tools like Swagger Codegen or OpenAPI Generator to generate specs first.
  • You need real-time API exploration (e.g., testing, debugging). Use tools like httpie, Postman CLI, or Insomnia.
  • Your CLI tools require heavy local processing (e.g., file I/O, complex business logic) beyond HTTP requests. This package focuses on API interaction.
  • You’re not using Laravel (though the package can be adapted for non-Laravel PHP projects with effort).
  • You prioritize SDKs or GUI tools over CLI. For SDKs, use OpenAPI Generator to generate client libraries.
  • Your API endpoints are highly dynamic (e.g., generated at runtime) and can’t be represented in OpenAPI specs.

How to Pitch It (Stakeholders)

For Executives:

*"This package turns our API specs into reusable, self-service CLI tools—like php artisan api:process-orders --status=pending—without writing custom scripts. It’s a game-changer for internal efficiency:

  • Faster tooling: Replace months of dev time for CLI wrappers with a one-time OpenAPI spec setup.
  • Empower teams: Let QA, support, or data teams run API calls directly (e.g., api:fetch-customer-data) without waiting for engineers.
  • CI/CD superpower: Trigger deployments or workflows via CLI (e.g., api:deploy --env=staging) with built-in error handling.
  • Future-proof: Add new API endpoints to the CLI by updating the spec—no code changes needed.

Example ROI:

  • A support team could resolve 30% more API-related tickets by using api:generate-report instead of manual API calls.
  • CI pipelines could cut API-related failure rates by 50% with automatic retries for transient errors.

It’s like giving our APIs a command-line interface—auto-generated, always in sync, and ready for anyone to use."*


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:

# Instead of writing a custom script for this API call:
curl -X POST https://api.example.com/users \
  -H 'Authorization: Bearer $TOKEN' \
  -d '{"name":"Alice"}'

# You get this intuitive, typed command:
php artisan api:post-users --input '{"name":"Alice"}' --auth-token $TOKEN

Key features:

  • Typed parameters: Path/query/body params become CLI flags (e.g., --user-id=123).
  • Auth integration: Supports Bearer tokens, API keys, or dynamic closures (e.g., OAuth refresh).
  • Error handling: Customize responses for 4xx/5xx errors (e.g., rate limits, permissions).
  • Laravel Zero ready: Build standalone CLI apps by registering APIs without namespaces.
  • Documentation built-in: The api:list command serves as interactive docs.

Use cases:

  • Replace ad-hoc scripts with maintainable, spec-driven commands.
  • Give non-engineers safe, documented access to APIs (e.g., QA testing api:post-users).
  • Add CLI endpoints to your Laravel app’s feature set with minimal effort.

Trade-offs:

  • Requires OpenAPI specs (but most modern APIs have them).
  • Best for HTTP-centric workflows; not a replacement for full SDKs or GUIs.

Pro tip: Pair this with Laravel Zero to build distributable CLI tools (e.g., php invoice-processor.phar generate --month=July)."*


For Data/QA/Support Teams:

*"No more asking engineers for API help! This tool lets you run API calls directly from the command line—like this:

# Fetch all active users
php artisan api:get-users --status=active

# Create a new order
php artisan api:post-orders --input '{"customer_id": 123, "items": [...]}' --auth-token $TOKEN

Why it’s awesome:

  • No coding needed: Just run commands like api:list to see all available endpoints.
  • Safe and documented: Every command is generated from the API spec—no guesswork.
  • Works with your tools: Use it in scripts, cron jobs, or even chat with AI agents to parse responses.

Example workflow:

  1. Run php artisan api:list to see all available commands.
  2. Use api:get-orders --status=pending to fetch data for a report.
  3. Pipe results into other tools (e.g., api:get-orders --status=pending | jq '.[] | .id').

Ask your dev team to set this up for your APIs—it’ll save you hours!"*

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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai