FlashDrive automatically builds your PHP app from your code.
In order to do that FlashDrive uses buildpacks to detect and build automatically your app.

You can fork or build this repository to get started with PHP on FlashDrive

To be able to build your app, FlashDrive needs a composer.json and a composer.lock files committed in your repository.

Prepare your app

Before pushing your app to git, run composer install locally to install the extensions and generate the composer.lock file from composer.json

More informations about composer

PHP Version

You can select the version of PHP using the composer.json file, for example :

  "require": {
    "php": "^7.4.16"

At this time, only the following version are supported :


If you don’t specify a version, FlashDrive will use automatically the latest version of PHP7 will be used.


A Procfile is used to inform FlashDrive what web server should be used with PHP and how to route it. The value (web or worker) must be consistent of the app settings you selected when you created the app.

Procfile is not mandatory with PHP, if you don’t specify one FlashDrive will uses Apache2. To use Nginx the Procfile should be something like that :

web: vendor/bin/heroku-php-nginx

And for Apache2 :

web: vendor/bin/heroku-php-apache2

You can also uses Procfile to specify the ROOT directory of your application :

web: vendor/bin/heroku-php-apache2 public/


composer.json is mandatory.
If you don’t need to use composer with your app, you can add an empty composer.json file like this one :


Note: if composer.json is empty, a composer.lock file is not required

App Dependencies

FlashDrive analyzes and build the app according to the composer.json file committed inside the Git repository, then you can let PHP scripts uses the extensions by adding this at the beginning of your PHP file :



Any .user.ini file that is commited into a repository will be loaded after the main php.ini See the instructions in the PHP manual for more details.

You can use these to set any directive permitted in PHP_INI_ALL, PHP_INI_USER and PHP_INI_PERDIR contexts.

Build Behavior

The following is run during build unless composer.json is empty and no composer.lock is present :

composer install --no-dev --prefer-dist --optimize-autoloader --no-interaction

Note : FlashDrive will not install development dependencies from the require-dev section of composer.json.

Custom compile scripts

Custom compile scripts can be added into the composer.json in form of a single line or multiple arguments :

  "scripts": {
    "compile": [
      "php app/console assetic:dump --env=prod --no-debug",

The custom compile command will be executed by the builder like this :

composer compile --no-dev --no-interaction

Default Behavior

Default web server is Apache2, you can uses Nginx by editing the Procfile but .htaccess files are not available with Nginx.

FlashDrive will launch a Fast CGI Process Managed and treats your Git root folder as the document root of the application, serving the .php files directly from that folder. Subsequent folders are served as well and you can alter this behavior using a .htaccess file.

Apache is setup with a Virtual Host that will respond to all hostnames. The document root is setup to be reachable without limitations and AllowOverride All is activated to allow for the use of .htaccess files.

Nginx uses a server that reply to all hostnames. The index directive is set to index.php index.html index.html

Maximum Execution Time

Maximum execution time is set to 30 seconds for all PHP applications except for the worker type. On FlashDrive, the routers have a maximum execution time of 600 seconds so this parameter can be increased to up to 600 seconds by creating a .user.ini file inside the root directory :

max_execution_time = 600

30 seconds is fine for most of the cases and you should keep the default max execution time if your apps doesn’t need to let scripts run longer than that.

You will also need to remove the default behavior of php-fpm that is set to drop the connection after 30 seconds. In order to do that commit a fpm_custom.conf into your git directory with this value :

request_terminate_timeout = 0

Then, commit a Procfile inside your root directory instructing the Heroku buildpack to launch the PHP server with your updated configuration :

web: vendor/bin/heroku-php-apache2 -F fpm_custom.conf public/

Note : FlashDrive uses the PHP buildpack published by Heroku, the mention to heroku in the code above is intentional and must be used for your app.

Create persistent storage

One of the major improvements of FlashDrive in comparison to others app hosting solutions is the ability to create Virtual Disks available for any copy of your app inside the same stack.

Virtual disks allow you to store data safely and securely, without the need to use an additional S3 bucket, and every app size gets free disk space depending on its size (see our pricing for more information).

In addition to that, Virtual disks are backup every day with 10 days history and ransomware protection at no additional cost.

Read this article for more informations about virtual disks and how to add one to your app.

Add a domain name

Please check this article for a detailled method on how to use your domain name with FlashDrive apps.

Define environment variables

Note: Environment variables set in your app settings are injected during the build process. If the build of your app needs to use an env variable make sure to set it before requesting the build.

FlashDrive lets you externalize the configuration of your app : the FlashDrive cluster will automatically injects the data when the app start or restart.

Environement variables can includes any external data your app needs to run like external ressources, databases addresses, encryption keys etc…

To add an environment variable, access your app settings and click “Add ENV Variable” :

Enter the key (like DATABASE_USER) and the value and click “Add”. FlashDrive will automatically add your environment variable and restart your app after a one minute delay (to let you add more env variables if necessary without restarting the app each time a new variable is added).

Provision a database

FlashDrive Marketplace includes all popular datastore engines including Mysql, Postgres, MongoDB and Redis.
To add a database to your app, click on Marketplace and select the database you want to run, then create the new app database inside the same stack as your PHP app.

Once the app is running, visit the database app’s settings and retreive the “internal name” :

Use this internal name as your would use a server address, for instance for mysql this name replace the usual “localhost”. Some scripts requires you to add the database port at the end of the server address. FlashDrive uses common port for each database software, for MySQL it will be 3306 and you can write is like that inside your scripts : internal-name:3306
Postgres usually uses credentials sent inside the login URL, like that : postgres://<user>:<password>@<internalname>:5432/<database>

The login and password information is available inside the Environment Variables of the database app.

Reach your app from another app

Inside your app stack, you can reach any other FlashDrive app member of this stack on any port. FlashDrive automatically routes the traffic internally and open the appropriate port. By opposition, your app is only reachable on ports 80/443 from outside of FlashDrive.

To reach your app internally, retrieve the internal name from your app settings page :

This name can be used to reach your app from another app inside the same stack. Use it in any form that works with your script :


Note : https:// is not available, all the traffic inside apps is already encrypted by the cluster.


FlashDrive uses at rest encryption for the app virtual disks, build images, and encrypted transport from inside the cluster. To make sure the traffic is encrypted between your app and the browser of your users you can set up SSL certificates for any domain name connected to the app (including the FlashDrive’s default domain name).

Scale your App

From your app settings you can scale your app vertically and horizontally : by upgrading the app size (refer to our pricing for app sizes details) or by adding more nodes.

Additional nodes will run another copy of your app inside another FlashDrive server located inside the same cluster (same geographical location). Traffic is automatically sent to the least occupied node by FlashDrive’s load balancer.

Note: Apps that use Virtual Disks will share the same file structure and read/write on the same disk. It’s fine in most cases for intensive read activity but can create bottlenecks and corrupted data if several nodes of the same app write on the same file at the same time. If your apps use intensive reads on virtual disks consider upgrading the app size instead of adding more nodes.

Was this helpful?

0 / 0