laravel/vapor-cli
Laravel Vapor CLI is the command-line client for deploying and managing Laravel apps on Laravel Vapor, a serverless, auto-scaling platform on AWS Lambda. Create and manage infrastructure, environments, queues, databases, Redis, networking, and more.
Installation:
composer require laravel/vapor-cli --dev
Ensure the package is autoloaded in composer.json under require-dev.
Authentication:
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY).~/.aws/credentials file.vapor auth:verify
First Use Case: Deploy a Laravel app to Vapor:
vapor deploy production --yes
vapor new in the Laravel Vapor dashboard).vapor or vapor list to see available commands.vapor/ directory in your Laravel app for configuration files (e.g., vapor.yml, queue.yml).Deployment Pipeline:
vapor serve to test Lambda functions locally.vapor deploy staging --yes
vapor deploy production --yes
vapor rollback production
Infrastructure Management:
vapor.yml and redeploy:
vapor deploy production --yes
vapor.yml to include new queues, databases, or Redis clusters, then deploy.Queue Management:
queue.yml (e.g., SQS, Redis).vapor.yml under queue:
queue:
worker:
concurrency: 25
Environment Variables:
vapor env to manage environment variables across stages:
vapor env:add production KEY=VALUE
CI/CD Integration:
vapor deploy in GitHub Actions/GitLab CI with AWS credentials as secrets.- name: Deploy to Vapor
run: vendor/bin/vapor deploy production --yes
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Local Development:
vapor serve --function=YourFunction.Monitoring:
vapor logs to stream Lambda logs:
vapor logs production --function=YourFunction
AWS Credentials:
vapor commands fail with AccessDenied errors.vapor, lambda, dynamodb, sqs, etc. Use the Vapor IAM Policy as a reference.aws sts assume-role) for CI/CD to avoid hardcoding keys.Configuration Mismatches:
vapor.yml between local and Vapor dashboard.vapor.yml with the dashboard after manual changes. Use vapor config:pull to fetch the latest configuration from Vapor.Cold Starts:
memory in vapor.yml (e.g., memory: 1024).reserved concurrency in vapor.yml:
functions:
your-function:
reserved: 1
Queue Timeouts:
Task timed out after X seconds.timeout in queue.yml (default: 900 seconds):
queues:
default:
timeout: 1800
Lambda Logs:
vapor logs to debug runtime errors. Filter by function:
vapor logs production --function=YourFunction --tail=50
Local Testing:
vapor serve and simulate events:
vapor serve --function=YourFunction --event='{"key":"value"}'
Dependency Issues:
composer.json is up-to-date.vapor deploy --no-warm to skip warm-up (useful for debugging).vapor/storage/logs for deployment logs.Custom Commands:
// app/Console/Commands/CustomVaporCommand.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Laravel\Vapor\Vapor;
class CustomVaporCommand extends Command
{
protected $signature = 'vapor:custom {action}';
public function handle(Vapor $vapor)
{
// Custom logic using $vapor->client
}
}
app/Console/Kernel.php.Pre/Post-Deploy Hooks:
deploy event to run scripts before/after deployment:
// app/Providers/EventServiceProvider.php
public function boot()
{
event(new \Laravel\Vapor\Events\Deploying);
// Add listeners for Deploying/Deployed events
}
Environment-Specific Configs:
vapor.yml per environment using vapor.yml.{stage} (e.g., vapor.yml.staging).# vapor.yml.staging
functions:
your-function:
memory: 512
WebSockets:
vapor.yml to use API Gateway with WebSocket support:
websockets:
enabled: true
routes:
- '/app/{channel}'
How can I help you explore Laravel packages today?