Provisioning Laravel Projects with Vapor CLI
Overview
Initializing a project with
Prerequisites
To follow this guide, you should have a functional
Key Libraries & Tools
- Vapor CLI: The primary tool for managing serverless deployments.
- Vapor Core: A required Composerpackage that provides the necessary service providers for the serverless environment.
- AWS VPC: Amazon Web ServicesVirtual Private Cloud, used to isolate your infrastructure.
Code Walkthrough
Navigate to your project root and execute the initialization command:
vapor init
Project Identification and Geography
The CLI first prompts for your Project Name. Following this, you must select an us-east-1 is more than a technicality; it is a latency decision. You want your code running as close to your end-users as possible to reduce round-trip times.
Installing the Core Provider
Once the project is registered, Vapor asks to install the core library:
composer require laravel/vapor-core
This package is non-negotiable. It contains the logic that allows
Syntax Notes
The vapor init command is idempotent regarding your local files but creates live resources in the vapor.yml file in your root directory, which acts as the blueprint for your environments and deployment hooks.
Practical Examples
- Staging vs. Production: Use environments to test new features in a mirror of production before a final rollout.
- Network Isolation: Vapor automatically creates a VPC (Virtual Private Cloud). This keeps your databases and caches hidden from the public internet, accessible only by your application.
Tips & Gotchas
Always verify your init. If Vapor fails to create a new Network (VPC), you might have hit the default
