Introduction
Deployments in Laravel Cloud happen whenever you have new code to release, new resources to attach, or environment settings that you want to update. When a new deployment is triggered, Laravel Cloud will take your code and environment settings, build a Docker image configured for your chosen PHP version, and then run your build and deploy commands. Once your build completes successfully, the existing deployment will be gracefully terminated (allowing any running processes to complete) and the new deployment will be brought online with zero downtime.
Deploy options
Push to deploy
Every time you push new code to your remote Git branch, a new deploy is automatically triggered. Push to deploy is enabled by default on all environments. To change this setting, go to Settings > Deployments.Deploy hooks
If you prefer to trigger a deployment via an HTTP endpoint, you can enable the “Deploy hook” option in Settings > Deployments. When enabled, you will be provided a URL that you can make a POST request to as part of your CI/CD flow. You can refresh your URL anytime from the Deployments settings. You can also deploy a specific commit by passing acommit_hash query parameter to the deploy hook URL. The commit hash should belong to the branch configured for the environment.
Example using GitHub Actions
Deploy hooks are perfect for integrating Laravel Cloud with your CI / CD pipeline. Here’s a complete example using GitHub Actions:-
First, add your deploy hook URL as a secret in your GitHub repository:
- Go to your GitHub repository settings
- Navigate to Secrets and variables → Actions
- Add a new secret named
LARAVEL_CLOUD_DEPLOY_HOOKwith your deploy hook URL
-
Create a
.github/workflows/deploy.ymlfile in your repository:
- Commit and push the workflow file to trigger your first deployment.
- Pull your code from the specified commit
- Run your configured build commands
- Run your configured deploy commands
- Deploy your application with zero downtime
Manual
You can trigger a deployment from the Laravel Cloud dashboard anytime by clicking the “Deploy” button from the Environment overview page or Deployments page. After updating environment settings, your changes are staged until you deploy them. Review everything that is pending and deploy the batch from the staged changes banner, or use the “Deploy” button at any time.Troubleshooting
Framework or runtime version not supported
- Laravel
- Symfony
- Next.js
- Nuxt
Laravel Cloud requires Laravel 9 or greater. In addition, you should be using the latest minor version of the
laravel/framework Composer package. The minimum minor versions required are:- Laravel 11:
v11.41.3 - Laravel 10:
v10.48.28 - Laravel 9:
v9.52.20
Deployment succeeds but serves no traffic
- Next.js
- Nuxt
Laravel Cloud’s in-pod proxy routes traffic to your application on the port set by the
PORT environment variable (3000 by default, or the port you chose when creating the application). The default start command, next start, reads PORT automatically, so this works out of the box for most applications.If you’ve overridden the start command with a custom server (for example, a server.js file using Express), the build can succeed even if that server listens on a different, hardcoded port. Laravel Cloud has no way to detect this, so the deployment goes live without routing any traffic to your application.Make sure your custom server reads the PORT environment variable rather than hardcoding a port number.
