Twelve-Factor Prestashop

by absalomedia


Twelve-Factor Prestashop

Prestashop, the Twelve-Factor way: fully managed using Composer and configured using environment variables. This has been heavily inspired by Wordpress 12 Factor

Code Climate StyleCI Codacy Badge Prestashop 1.7.1 Patreon

General Concepts and Considerations

The Prestashop installation is fully contained in a shop1 subfolder upon Heroku deployment. A resides in the root of the project, and uses several different environment variables to control behavior.

The configuration file is kept as generic as possible; on Heroku, add-ons JawsDB (for MySQL) and SendGrid (for E-Mails) are used.

The assumption is that this installation runs behind a load balancer whose X-Forwarded-Proto header value can be trusted; it is used to determine whether the request protocol is HTTPS or not.

Quick Deploy

If you have a Heroku account, you may simply use the following button to deploy this application:


After the deploy, in Heroku's Dashboard under "Settings" for your deployed application, remove the PRESTASHOP_ADMIN_* environment variables.

Manual Deploy


Clone this repo:

$ git clone
$ cd prestashop-12-factor

If you like, you can locally install dependencies with Composer:

$ composer install

Create Application and Add-Ons

Create a new app and add add-ons for MySQL and E-Mail:

$ heroku create
$ heroku addons:create jawsdb
$ heroku addons:create sendgrid


$ git push heroku master

Finalize Installation

This will create tables and set up an admin user:

$ heroku run 'composer prestashop-db-core --name='Prestashop on Heroku' --db_server=localhost --db_name=prestashop --db_user=admin --db_password=admin '

Visit ecommerce store

Navigate to the application's URL, or open your browser the lazy way:

$ heroku open

Updating Prestashop and Plugins

To update all dependencies:

$ composer update

Environment Variables will use the following environment variables (if multiple are listed, in order of precedence):

Database Connection

DATABASE_URL or JAWSDB_URL or CLEARDB_DATABASE_URL (format mysql://user:pass@host:port/dbname) for database connections.