Prestashop, the Twelve-Factor way: fully managed using Composer and configured using environment variables. This has been heavily inspired by Wordpress 12 Factor
The Prestashop installation is fully contained in a shop1
subfolder upon Heroku deployment. A settings.inc.php
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.
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.
Clone this repo:
$ git clone https://github.com/absalomedia/prestashop-12-factor
$ cd prestashop-12-factor
If you like, you can locally install dependencies with Composer:
$ composer install
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
This will create tables and set up an admin user:
$ heroku run 'composer prestashop-db-core --name='Prestashop on Heroku' --domain=example.herokuapp.com --db_server=localhost --db_name=prestashop --db_user=admin --db_password=admin [email protected] '
Navigate to the application's URL, or open your browser the lazy way:
$ heroku open
To update all dependencies:
$ composer update
settings.inc.php
will use the following environment variables (if multiple are listed, in order of precedence):
DATABASE_URL
or JAWSDB_URL
or CLEARDB_DATABASE_URL
(format mysql://user:pass@host:port/dbname
) for database connections.
SENDGRID_USERNAME
and SENDGRID_PASSWORD
for SendGrid credentials.