Introduction
Laravel Cloud applications can be made up of many environments, such as “production”, “staging”, or even short-lived environments used for trialing new features you’re developing for your application. Compute infrastructure, resources, and deployment settings are unique to each environment, allowing you to fine-tune each environment based on its purpose. For example, you might wish to assign small Flex compute instances that scale to zero to your staging environment, while larger, always-on compute instances are assigned to your production environment.Build and deploy commands
You may define how your application is built during deployment from the Deployments section of your environment settings.Build commands
Build commands allow you to customize the build process for your application during deployment.- Laravel
- Symfony
- Next.js
- Nuxt
- JavaScript
- Go
- Python
Typically, your Laravel build command will install your Composer and npm dependencies and compile your application’s assets:
Private Composer packages
To allow the installation of private Composer packages, you will need to configure your application’s Composer HTTP authentication credentials for each package using thecomposer config command. You should add this command to your build commands prior to invoking composer install:Dynamic environment variables
Build commands run with your environment’s variables loaded from a.env file in the build context, so you may append to that file to derive a variable during the build:
JavaScript applications using Node.js, Bun, or Deno, along with Go and Python applications, receive their variables on the application process rather than from a
.env file. A variable appended during the build is visible to later build commands but not to your running application. Add it under your environment’s environment variables instead.Deploy commands
Your environment’s “Deploy Commands” are run on your Laravel Cloud infrastructure just before a new deployment goes “live”. Typically, these commands will be used to migrate your environment’s database. Unlike build commands, changes made to the filesystem by deploy commands will not be persisted to your application.
Unnecessary build and deploy commands
This section applies to Laravel applications.
php artisan queue:restart- Queue workers are automatically restarted after each deploymentphp artisan horizon:terminate- Horizon processes are automatically managed during deploymentsphp artisan optimize:clear- This clears the cache and can cause unexpected behavior, especially related to the queuephp artisan storage:link- The symbolic link won’t persist as changes made during deploy commands are not saved. Use Laravel Object Storage for persistent file storage instead.
Environment settings
Environment variables
Within your environment’s settings, the environment variables section allows you to customize the variables available to your environment.

Custom environment variables take priority and will override any automatically injected environment variables.
How variables reach your application
Laravel Cloud delivers your environment’s variables differently depending on the runtime:- Laravel, Symfony
- JavaScript
- Go
- Python
Laravel Cloud writes your variables to a
.env file in your application’s root directory before your application starts, so the framework reads them the same way it does locally..env file in the build context, whatever the runtime. That file is a build-time artifact; the values your application reads once it is running come from the process environment.
HTTP basic authentication
HTTP basic authentication allows you to protect an environment with a username and password before traffic reaches your application. This is useful for staging environments, private demos, preview environments, or sleeping environments that should not wake up because of unauthorized requests or automated bot traffic. You may enable HTTP basic authentication from your environment’s General Settings page in the Security section. When enabled, users can access the environment using the usernameadmin and the password you set. Passwords must be between 5 and 32 characters and cannot contain the : character.

Runtime
PHP runtime
You may select the PHP version that should be used by an environment on the environment’s General Settings page. After changing the PHP version, a re-deployment is required in order for the changes to take effect. See Runtimes for the supported PHP versions.
Node.js, Bun, and Deno runtimes
Next.js, Nuxt, TanStack Start, Express, and Hono applications run on the Node.js, Bun, or Deno runtime, detected automatically from the configuration files in your repository. See Runtimes for detection rules and supported versions. The Node.js version is selectable on the environment’s General Settings page; after changing it, a re-deployment is required for the change to take effect. Bun and Deno applications run on a fixed version and don’t offer version selection in the dashboard.
Go and Python runtimes
Go and Python applications are detected automatically from your repository: ago.mod file for Go, or a pyproject.toml, requirements.txt, Pipfile, or setup.py file for Python. Rather than a dashboard setting, Laravel Cloud reads the language version straight from your repository (the go directive in go.mod for Go; a .python-version file or the requires-python constraint in pyproject.toml for Python). See Runtimes for supported versions and what happens when a detected version isn’t one Laravel Cloud publishes.
PHP extensions
PHP extensions are only available for PHP runtime environments (Laravel and Symfony).
php -m using Laravel Cloud’s “Command” feature in your environment dashboard.
PHP memory limit
This section applies to PHP runtime environments (Laravel and Symfony).
memory_limit.
You can override the default memory limit by adding configuration directly in your application code. The most common method is to update your public/index.php and your artisan file:
Cloud domains
Each Laravel Cloud environment is assigned a freelaravel.cloud domain the first time it is deployed successfully. This makes it easy to test and build your application before attaching a custom domain.
Laravel Cloud domains are constructed using a combination of your application and environment name. If either of these names are changed, the Laravel Cloud domain will be updated to reflect the changes. A redeployment is required for this change to take effect.

Custom domains
Of course, before shipping your application to the world, you will likely want to assign your own custom domain name to your production environment. Laravel Cloud will guide you through DNS configuration, verify domain ownership, and issue an SSL certificate automatically. For comprehensive documentation (DNS records, verification paths, wildcards, provider-specific guides, and plan limits), see Domains.Stop and restart
To stop an environment, click the ”…” button next to the environment’s “Deploy” button. Then, click “Stop”. When you stop an environment, all App and Worker clusters within the environment will be shutdown. This means all web traffic, background processes, and scheduled tasks will stop processing. You will not be charged for the environment’s compute, but you will still be charged for any attached resources. You can restart the environment using the same dropdown menu. A full deployment is required to restart an environment.
Replicate
It is common for environments in the same application to have similar or identical resource and settings configurations. Therefore, when creating new environments, it is often more convenient to clone an existing environment and make changes rather than creating a new environment from scratch. To replicate an environment, click the ”…” button next to the environment’s “Deploy” button. Then, click “Replicate”. Confirm you are replicating the correct environment and Git branch, then enter a name for your new environment. By default, all General, Environment, and Deployment settings will be duplicated. You can optionally edit the default replication settings for compute and resources. The default replication behavior is:- Compute: duplicate all clusters at a smaller size, with Scale-to-Zero enabled
- Database: create a new database cluster that scales to zero, or a new database within the same cluster if your database does not support scale-to-zero replication
- Cache: create a new cache that scales to zero, or a new cache at the smallest available size if your cache does not support scale to zero
- Object storage: create a new bucket
- WebSockets: create a new WebSocket server
REDIS_PREFIX environment variable set to application:environment: so each environment’s keys stay separate. If the environment runs Laravel Horizon, Cloud also sets HORIZON_PREFIX.

Commands
Laravel Cloud allows you to execute arbitrary shell commands directly in your environment. Navigate to your environment’s Commands tab to run one-time commands for any supported framework or runtime. For example,php artisan cache:clear in a Laravel application, php bin/console cache:clear in a Symfony application, node script.js in a Node.js application, ./app migrate in a Go application, or python manage.py shell in a Django application.
Commands will be executed on any available instance in your environment.
Filesystem
Environment filesystems are ephemeral, meaning files may not persist across requests or jobs. New deployments or re-deployments will reset the filesystem. In addition, each replica of your compute cluster has its own filesystem. Thus, you should treat the filesystem as temporary, unshared disk space that is only consistent during a single request or job. The total disk space available on each replica is proportional to the compute / RAM of the cluster. Every 1GB of RAM is equal to 512MB of disk space. For example, a cluster with 2GB of RAM will have 1GB of ephemeral disk space available to it. If you exceed the available disk space, your application may crash and the deployment may need to restart. For persistent cache and session storage, PHP applications should use theredis or database drivers via a cache or database resource. JavaScript applications should use their framework’s equivalent persistent session and cache adapter backed by one of these resources. Go and Python applications should connect directly to a cache or database resource using the injected REDIS_URL or DATABASE_URL connection string. For persistent file storage, use Laravel Cloud Object Storage.
Nightwatch integration
Nightwatch integration is currently available for Laravel applications only.

1
Install Nightwatch package
Install the Laravel Nightwatch package in your application locally using Composer:
Run
composer require laravel/nightwatch on your local machine to update your composer.json and composer.lock files before deploying.2
Connect Nightwatch
Click the Connect Nightwatch button in your environment dashboard.
3
Enable monitoring
Toggle Enable monitoring to activate Nightwatch for your environment.
4
Enter your Nightwatch token
Enter your Nightwatch token, which you can find in your Nightwatch application settings.
Enabling Nightwatch will automatically run the agent across all the App and Worker clusters in the environment. You can setup Nightwatch manually if you want the agent to run on specific instances.

