This is a dockerized basic project structure for PHP development.
Your code should go into ./src
- Exposed ports (host:container): 80:80
- Web server: apache
- PHP version: 7
- Installed extensions: PDO (MYSQL,SQLITE)
- DB: MYSQL
- DB hostname(what to put in your code): 'db'
- DB environment is defined in ./db/env
How to import a database dump on startup?
Just put your file at ./db/schema.sql
How to import a .sql later on, after the startup?
cd db
bash import.sh mydump.sql
# Clone repo
git clone https://github.com/IOAyman/docker-phpdev.git myawesomeproject
cd myawesomeproject
# Do the house cleaning
python clean.py -h
usage: clean.py [-h] [-git] [-db dbname root_password user user_password]
Clean and re-initialize your project folder
optional arguments:
-h, --help show this help message and exit
-git Re-initialize a git repository
-db dbname root_password user user_password
Change the default database creadentials
# Run the containers
docker-compose -d up
# Test
curl localhost
# Shutdown the containers
docker-compose down