Overview: The Shift to Fully Managed Infrastructure Moving a high-traffic production application like Laravel News from a managed server environment like Laravel Forge to a serverless, fully managed platform represents a significant evolution in how we think about hosting. For years, developers have relied on provisioning Linode or DigitalOcean droplets through Forge, which strikes a great balance between control and convenience. However, the manual overhead of scaling for traffic spikes, updating PHP versions, and managing security patches remains a persistent distraction from the core task of building features. Laravel Cloud solves this by abstracting the server away entirely. Instead of managing a "box," you manage an environment. This tutorial walks through the live migration of a real-world asset, demonstrating how to provision resources, sync environment variables, and execute a zero-downtime domain cutover. The goal is simple: eliminate the need for developers to "buy a bigger boat" every time a CPU spike hits, replacing manual intervention with automated, intelligent scaling. Prerequisites & Preparation Before initiating a migration of this scale, you need to ensure your application is container-ready. While Laravel Cloud handles the orchestration, the underlying architecture relies on Docker images. * **Environment Parity**: Ensure your local development environment—ideally using Laravel Herd—mirrors the production PHP version as closely as possible. * **Stateless File Storage**: Any files stored on the local disk of a Forge server must be moved to object storage like Amazon S3 or Cloudflare R2. Since cloud instances are ephemeral, local disk storage will not persist across deployments. * **DNS Access**: You must have access to your DNS provider (e.g., Cloudflare) to modify CNAME records during the final cutover phase. Key Libraries & Tools * **Laravel Cloud**: The primary deployment platform and infrastructure orchestrator. * **Laravel Valkyrie**: The managed cache solution optimized for high-performance Laravel applications. * **TablePlus**: A database management GUI used for importing legacy data into the new cloud cluster. * **Cloudflare**: Used for DNS management and as a proxy to ensure SSL and edge caching. * **Algolia**: The search engine integrated into the app, which requires careful handling during data seeding to avoid duplicate indexing. Code Walkthrough: Provisioning and Deployment 1. Resource Provisioning The first step involves creating the infrastructure pillars: the database and the cache. In the cloud dashboard, adding a resource automatically handles the "plumbing." ```bash Example of how environment variables are injected automatically DB_CONNECTION=mysql DB_HOST=your-cluster-id.cloud-region.aws.com DB_DATABASE=main CACHE_DRIVER=valkyrie ``` When you add Laravel Valkyrie or a MySQL cluster, the platform injects these secrets directly into the container runtime. You do not need to copy-paste hostnames manually, which reduces the surface area for configuration errors. 2. Customizing Build and Deploy Commands Every application has unique build requirements. For Laravel News, we needed to ensure Filament component caches were cleared during the build phase. Unlike Forge, where you might run these on the live server, Laravel Cloud distinguishes between **Build Commands** (which run while creating the image) and **Deploy Commands** (which run just before the new version goes live). ```bash Build Commands php artisan filament:cache-components Deploy Commands php artisan migrate --force ``` 3. Handling the Database Import Since we are moving to a new cluster, we must bridge the data. By enabling a **Public Endpoint** temporarily on the cloud database, we can connect via TablePlus and import the legacy SQL dump. *Note: Always disable the public endpoint once the import is complete to maintain a secure, private network perimeter.* Syntax Notes: The Environment Canvas The UI introduces the concept of the **Environment Canvas**. This visual representation shows the relationship between your **App Cluster** (the compute), your **Edge Network** (the domains), and your **Resources** (data stores). Notable features include: * **Flex vs. Pro Compute**: You can toggle between different CPU and RAM allocations. For a site like Laravel News, starting with a "Pro" size (2 vCPUs, 4GB RAM) provides a safety buffer during the initial migration traffic. * **Auto-scaling Replicas**: You define a minimum and maximum number of replicas (e.g., 1 to 3). The platform monitors HTTP traffic and spins up new instances automatically when load increases, then spins them down to save costs when traffic subsides. Practical Examples: Real-World Use Cases Beyond simple hosting, the migration enables advanced workflows like **Preview Environments**. Imagine a partner wants to see a new advertisement placement before it goes live. In the old Forge world, you might have to manually set up a staging site. With Laravel Cloud, every Pull Request can trigger a temporary, isolated environment with its own URL. ```bash Logic flow for Preview Environments 1. Developer creates a branch 'new-ad-feature' 2. GitHub Action triggers Laravel Cloud 3. Cloud provisions a temporary compute instance and database 4. URL generated: https://new-ad-feature.laralnews.preview.cloud 5. Partner reviews; Developer merges PR; Cloud destroys the temporary environment ``` Tips & Gotchas * **The Log Trap**: If you see a 500 error immediately after deployment, check your log driver. Laravel Cloud manages logging automatically; manually setting `LOG_CHANNEL=stack` or similar in your custom environment variables can sometimes conflict with the platform's internal log aggregation. * **Queue Connections**: By default, the platform might assume a `database` queue driver. If you haven't run your migrations or created the `jobs` table yet, your application might crash during the seeding process if it attempts to dispatch a background job. Set `QUEUE_CONNECTION=sync` temporarily during the initial setup to ensure seeds finish without error. * **Statelessness**: Remember that the `/storage` directory is not persistent. If your application allows users to upload avatars (as Eric Barnes discovered during the live stream), those images will vanish on the next deploy unless they are stored in a persistent bucket like Amazon S3 or Cloudflare R2.
TablePlus
Products
Laravel (6 mentions) promotes TablePlus as a vital GUI for importing legacy data and managing Docker containers in videos like "Sail - Docker for Laravel made simple."
- Jan 22, 2026
- Dec 5, 2025
- Mar 4, 2025
- May 15, 2024
- Feb 25, 2021
The Mission to Lower the Barrier to Entry Software development moves fast, and even established ecosystems can accumulate technical debt in their documentation. For Laravel, the goal has always been to provide the most accessible entry point for web developers. However, as the stack evolved to include complex frontend tools and various local environment managers like Valet or Homestead, the onboarding process became fragmented. The introduction of Laravel Sail represents a fundamental shift toward a unified, containerized development environment that works regardless of the user's local machine configuration. The philosophy behind this update is simple: a developer should be able to go from a fresh laptop to a running application with nothing but Docker Desktop installed. By removing the need to manually configure local versions of PHP, MySQL, or Node.js, the framework eliminates the "it works on my machine" friction that often plagues newcomers. This isn't just about convenience; it is about ensuring the longevity of the ecosystem by making it the obvious choice for both students and seasoned professionals. Prerequisites and Environment Setup Before jumping into the commands, you need a basic understanding of Docker concepts, such as containers and images. While you don't need to be a Docker expert, knowing that your application runs in an isolated environment is key. Ensure you have Docker Desktop installed and running on your machine. For Windows users, Taylor Otwell strongly recommends using Windows Subsystem for Linux 2 (WSL2) to ensure the filesystem performance remains snappy. Key Libraries and Tools * **Laravel Sail**: A light CLI shim for interacting with Docker Compose. * **Laravel Breeze**: A minimal, simple starter kit for authentication using Blade and Tailwind CSS. * **Mailhog**: An email testing tool that captures outgoing mail for easy previewing. * **Composer** & **npm**: Dependency managers for PHP and JavaScript, respectively, both of which run inside the Sail containers. Code Walkthrough: Building Your First App The initialization starts with a simple curl command that fetches a specialized installation script. This script handles the Docker heavy lifting for you. ```bash curl -s https://laravel.build/example-app | bash ``` This command triggers a small, temporary Docker container that runs Composer to create the project directory. Once the process finishes, you navigate into the folder and start the environment: ```bash cd example-app ./vendor/bin/sale up ``` The `up` command initializes the Docker Compose stack defined in your `docker-compose.yml`. On the first run, this pulls the necessary images for PHP 8.0 (or 7.4), MySQL, Redis, and Mailhog. Once the containers are active, your application is live at `http://localhost`. To interact with the environment, Sail provides proxies for common commands. Instead of running a local version of Artisan or PHP, you prefix your commands with `sail`: ```bash sail artisan migrate sail composer require laravel/breeze --dev sail npm install && sail npm run dev ``` These commands execute inside the container, ensuring that the environment exactly matches what is defined in your project configuration. Syntax Notes and Best Practices A major convenience factor involves setting up a bash alias. Typing `./vendor/bin/sail` every time is tedious. By adding `alias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'` to your shell profile, you can simply type `sail` for all interactions. Another notable pattern is the use of Laravel Breeze for authentication. While Jetstream offers advanced features like team management and two-factor authentication, Breeze is preferred for those learning the ropes because it publishes simple Blade templates and controllers directly into your app. This makes the code transparent and easy to modify. Practical Examples and Debugging One of the most practical features included in the default Sail stack is Mailhog. In a traditional environment, setting up an SMTP server for local testing is a chore. With Sail, you simply visit `http://localhost:8025` to see every email your application sends. If you need to perform manual database maintenance, you don't need a special Docker GUI. Tools like TablePlus can connect directly to `127.0.0.1` on port `3306`, as Sail maps the container's internal ports to your local host by default. Tips and Gotchas * **Permissions**: On Linux, you might encounter file permission issues when Docker creates files as the root user. Sail attempts to handle this by mapping your local user ID to the container user. * **Existing Services**: If you already have MySQL or Apache running on your host machine, Sail may fail to start because ports 80 or 3306 are already taken. Be sure to stop local services before running `sail up`. * **Version Switching**: You can easily toggle between PHP versions by changing the build context in your `docker-compose.yml` and rebuilding the containers with `sail build --no-cache`.
Dec 8, 2020