Provides a minimal structure for a local-dockerized php project targeted for Heroku.
-
Is this public, incognito or private
-
- for addons
- description
- and check if
heroku.yml
is already widely supported and you wanted to migrate
-
- author
- autoload namespace
- name, description, keywords
- license
- requirements: versions still valid?
-
Review and edit docker-compose.yml
- services: which are needed, which are not
- environment variables
-
- add more for Symfony et alia?
-
- still fine to use nginx?
- and check if
heroku.yml
is already widely supported and you wanted to migrate
-
Review and edit cnfiguration files or variables
- consider to log to php://stderr (and/or stdout) in production
- Symfony 4:
- Trusting the Load Balancer
- Steps to start with Postgres
-
Setup git:
- clone this boilerplate
-
NEW_PROJECT_NAME=FOOBAR; \ git clone https://github.com/ebln/php-heroku-boilerplate.git ${NEW_PROJECT_NAME} && cd ${NEW_PROJECT_NAME}
- optional
rm -rf .git && git init
# to flush boilerplate's git history
- optional
-
- or
git init;
- configure git for your privacy demands
git remote remove origin; \ git config --list; \ git config user.email "sokolow@net.invalid"; \ git config user.name "Распутин"; \ git config --list --show-origin;
- if this is a new repository, run:
git add -A && git commit -m 'Initial commit'
- Create a new (origin) repository
-
REPOSITORY_NAME=FOOBAR; \ git remote add origin git@github.com-ebln:ebln/${REPOSITORY_NAME}.git
- and push
git push -u origin master
- clone this boilerplate
-
Setup docker and debug prerequisites
- add
127.0.0.1 php.local
to/etc/hosts
- to use xdebug export your local IP:
export XDEBUG_REMOTE_HOST=10.0.0.1
- add
-
Setup Heroku
- assuming Heroku CLI was installed
sudo snap install heroku --classic
heroku login
- Create app
heroku apps:create --region eu
- CAVEAT: auto-provision of addons and env·s via app.json seems not to work with git deployments
- Provisioning app
- add addons
- add environment variables
- either via web interface or CLI
- assuming Heroku CLI was installed
-
Setup code
composer.phar install && git add composer.lock && git commit -m 'Add composer.lock'
-
Push to Heroku
- for Symfony 4 set these environment variables
heroku config:set APP_ENV=prod APP_SECRET=$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32)
git push heroku master
- check
heroku open
- for Symfony 4 set these environment variables
-
Use Docker for local development
docker-compose up -d
- application at http://php.local:8080
- Adminer http://localhost:8081/?pgsql=db&username=postgres
-
Docker clean-up
docker system prune --all
(keeps data volumes)docker system prune --all --volumes
(deletes data volumes)