PHP development environment with Docker
Today I will tell you, how can you create development environment with Docker.
First, check Docker installation. Type in console:
docker version
You should see actual Docker version. If you don’t see it, then you’ll first install Docker:
https://docs.docker.com/engine/getstarted/step_one/#step-2-install-docker
If your installation is positively verified, then we will start.
In my project “Image optimizer API” I will use PHP7, MySQL and Nginx.
All this can we find here:
https://github.com/hamptonpaulk/php7-dockerized
We can install all in 3 easy steps:
1. Clone repository:
git clone https://github.com/hamptonpaulk/php7-dockerized.git
2. Adjust “docker-compose.yml” file. Change default MySQL password:
MYSQL_ROOT_PASSWORD: yourNewPassword
3. Run command:
docker-compose up -d
Be patient, first time Docker must download all required images.
When the script finishes the operation, then you’ll check result in browser:
http://localhost/
You should see phpinfo result:
For MySQL connection, I use “Sequel Pro“. You can use an alternative program or install phpMyAdmin.
Congratulations! That’s all. You can start coding. Your code should be in “www/” folder.
Enjoy!
If you have a problem with MySql connection check this post:
http://bsosna.com/2017/04/23/how-to-connect-php-container-with-mysql-container/
No Comment