Laravel is a PHP web application framework with expressive, elegant syntax. This guide walks you through the minimal requirements to successfully deploy your app.
Deploying a Laravel application on Clever Cloud requires:
The following sections explain how to set up each instance step by step:
From the Clever Cloud Console, create a new PHP application and choose your deployment method: git, GitHub or FTP.
Add the following environment variable in the Console:
Or set it with the Clever Cloud CLI:
clever env set CC_WEBROOT /public
config/app.php contains the following line:
'key' => env('APP_KEY'),
php artisan key:generate. It should output something like
Copy this value and add an environment variable named
APP_KEY, with this value.
config/logging.php contains the following line:
'default' => env('LOG_CHANNEL', 'stack'),
In your environment variables, add the
LOG_CHANNEL=syslog environment variable. This allows you to read your application logs directly from the console or the CLI tool.
CC_PRE_RUN_HOOK environment variable.
CC_PRE_RUN_HOOK="npm install && npm run prod".
This step is necessary if you are building your Laravel application with Blade, for example.
config/database.php to set the correct environment variable names. For example, replace
MYSQL_ADDON_xxx for a MySQL database.
For instance for MySQL:
Create a database add-on (either MySQL or PostgresSQL) and link it to your application. If your add-on already exists, use the Service Dependencies > Link add-ons dropdown menu in your application options, to select the name of the add-on you want to link and use the add button to finish the process.
If you want to have database migrations automatically run during each deployment, add this hook instruction to the application’s environment variables
CC_POST_BUILD_HOOK=php artisan migrate --force
Create a FS Bucket add-on and link it to your application. Note its host (you can see it from the add-on configuration panel, or in the environment variables exported by the add-on). It looks like
Create a new environment variable called
CC_FS_BUCKET and set
/storage/app:<bucket-host> as its value.
If your app uses task scheduling, you need to configure a cron to run the scheduling process:
- Create a
clevercloud/cron.jsonfile in your project, containing:
"* * * * * $ROOT/clevercloud/cron.sh"
This installs a cron to run
clevercloud/cron.sh every minute.
- Create a
clevercloud/cron.shfile in your project (with execute permissions), containing:
set -euo pipefail
php artisan schedule:run >> /dev/null 2>&1
Note: the PHP CLI process uses a
memory_limit configuration value that depends on the instance’s size (you can verify this value by connecting to your app using SSH and running
If one of your scheduled tasks needs to allocate more memory than this limit, the
php artisan schedule:run process is going to silently crash.
To allow it to use more memory, you can call
ini_set() inside a
php_sapi_name() === 'cli' condition from an early hook to the app’s lifecycle (like the
See this Gist for an example implementation.
To ensure Laravel correctly handles HTTP requests when using the Clever Cloud HTTP reverse proxy (Sōzu), add the following code to the
This environment variable exists in any Clever Cloud instance. This configuration specifies to trust Clever Cloud proxies, allowing Laravel to seamlessly recognize HTTP requests in the presence of a proxyhugo server.
Need more configuration? To run a script at the end of your deployment? To add your private SSH key to access private dependencies?
Go check the Common configuration page.
You may want to have an advanced usage of your application, in which case we recommend you to read the Administrate documentation section.
If you can’t find something or have a specific need like using a non supported version of a particular software, please reach out to the support.
Did this documentation help you ?