- How do I install Mailcoach CLI in a Laravel project?
- Use Composer to install it as a dev dependency: `composer require spatie/mailcoach-cli --dev`. Then run `php artisan boost:install` if using Laravel Boost. For standalone use, install globally with `composer global require spatie/mailcoach-cli`.
- What Laravel versions does Mailcoach CLI support?
- The package is officially tested with Laravel 13+. For older versions, use the standalone CLI or ensure compatibility with your PHP version (8.1+). Check the Boost docs if integrating with Laravel 12 or below.
- How do I authenticate the CLI with my Mailcoach instance?
- Run `mailcoach login` and provide your Mailcoach URL (e.g., `https://your-instance.mailcoach.app`) and an API token from `/account/api-tokens`. Credentials are stored securely in `~/.mailcoach/config.json`.
- Can I use this CLI without Laravel (e.g., in a PHP script)?
- Yes, install it globally with `composer global require spatie/mailcoach-cli` and use it anywhere. However, Laravel-specific features like Boost integration or service container binding won’t be available outside Laravel projects.
- How do I handle API rate limits or throttling with this CLI?
- The CLI doesn’t include built-in retry logic for rate limits, but you can wrap commands in your own scripts using exponential backoff. Monitor Mailcoach’s API docs for rate limits and adjust your workflows accordingly.
- What happens if Mailcoach’s API changes or breaks?
- The CLI auto-generates commands from the OpenAPI spec, so new endpoints are added automatically. Run `mailcoach clear-cache` to refresh the spec if Mailcoach updates its API. Monitor their changelog for breaking changes.
- How do I integrate this CLI with AI agents like Claude or Copilot?
- Install the AI skill via `npx skills add spatie/mailcoach-cli` or manually copy the skill files to your agent’s directory (e.g., `.claude/skills/mailcoach/`). The skill enables agents to run Mailcoach commands directly.
- Is there a way to test CLI commands in CI/CD without hitting Mailcoach’s API?
- Yes, mock the Mailcoach API in your tests by intercepting HTTP requests or using a local Mailcoach instance. The CLI itself doesn’t include built-in mocking, but you can test commands by validating their output against expected API responses.
- How secure is storing API tokens in `~/.mailcoach/config.json`?
- The file is stored locally and isn’t encrypted by default. For production, consider using Laravel’s `.env` or a secrets manager (e.g., HashiCorp Vault) instead of relying on the CLI’s default storage.
- What are the alternatives to Mailcoach CLI for managing Mailcoach via the API?
- Alternatives include writing custom Guzzle HTTP clients or using Mailcoach’s official API directly. However, this CLI provides auto-generated commands, reducing boilerplate and keeping you aligned with Mailcoach’s API updates.