DEV Community

Jhonatan Morais
Jhonatan Morais

Posted on

Dev Environment with docker, php and Xdebug3!

“If I had eight hours to chop down a tree, I’d spend the first six of them sharpening my axe.”
― Abraham Lincoln

I love that quote! known well our tools allow us to be more productive and because I love that too today Im going to share my personal docker image which has been helping day by day to keep my axe shaped!

I wrote other post about some topic years ago, but it needs some update here is it.

The final product of this guide will be a docker image with a nginx webserver with php-fpm, x-debug and some other hints to support you day-to-day web development using node, queues, redis etc...

In the next lines you will find a introduction about how to use this image, but if you prefer you can just watch my explanation video

The dockerFile and The docker-compose.yml

Lets save our time... so please visit my repository on git to checkout, build and use this as local environment to your purposes. The README file will offer extra instructions to you.

Project scaffold and usage

Project scaffold. Next section descripes each entry

php-nginx/ -> Main Project folder
   config/ -> Config shared between host and container
      nginx -> Hold ngnix configuration
         default.config -> each file here maps a host
   docker-compose.yml -> manager your containers
   dockerFile -> Recipe to build your dev environment
   workspace -> Place to add your projects
      -> default/ -> Project defaults, mapped by ngnix.   
Enter fullscreen mode Exit fullscreen mode

The idea is simple like this, each new project should be added into workspace/ folder and each one should have a new nginx file to set it own hostName and documentRoot. Of course remember to set/map your hostName into your local hosts files. Again, all the steps are fully described in the README file

It is important to remember this a a image to local development purposes, so to production and pipeline environment you should create another images.

Please like it, comment and share.
If you have any question just write it in the comments.

Top comments (0)