todokku / php-heroku-boilerplate

PHP foothold: locally dockerized, targeted for Heroku

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-heroku-boilerplate

Provides a minimal structure for a local-dockerized php project targeted for Heroku.

Consider

Setup

  • 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
    • 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
  • 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
  • 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
  • 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
  • Use Docker for local development

  • Docker clean-up

    • docker system prune --all (keeps data volumes)
    • docker system prune --all --volumes (deletes data volumes)

About

PHP foothold: locally dockerized, targeted for Heroku

License:Other


Languages

Language:Shell 46.5%Language:Dockerfile 40.4%Language:Makefile 11.9%Language:PHP 1.2%