PHP web development environment with Docker tutorial – 001

11 thoughts on “PHP web development environment with Docker tutorial – 001

  1. Great to see good content shared on youtube. I'm a new subscriber now. Thank you very much for the great tutorial series.

  2. I wish I found this tutorial before I started on my own similar setup.

    However my setup got little different. I managed to separate Apache and PHP in separate containers using the php-fpm (php:7.1.27-fpm-alpine3.8). Apparently its good practice to have each services in a separate container. I used the Alpine version, to make the image smaller. I have not yet started to look into composer yet, so for I only setup so my PHP have support for redis, rabbitmq, sphinx and mysql (all of these in a separate container). I found your tutorial when I looked in how to get xdebug working. However I want my to setup to work on windows, linux and OSX, so thats why I don´t want to build anything outside the containers.

    I also have a different folder structure:
    ./Data: Here is data that the services needs after they started first time like mysql, redis and rabbitmq
    ./Services: here are docker files and files they need to start up
    ./public_html: Here I put all the code I use that I will develop for each project

    However I think I need to re-design this since I should prefer to have it as a git sub repo, so if update this base I want it to be in all of my project that use it. I thought if looking into get more configurable what services I start since I might not need RabbitMQ for all my projects. So that is also on my todo list.

    But most important for me its easy get up and running with all my familiar services, so if that can be achieved with just one line I'm happy even if I get extra services running. Also that it works on all 3 big platforms without adding some extra programs beside docker.

    In your approach you need to redo all your steps for each project. So think my approach is better in this way. However I understand this tutorial was do demonstrate how just set it up, but still think it could be worth to do the extra steps get it more generic. What do you think? If you want I could share my code with you?

  3. I have just one Question: can I use Zend Expressive to build Enterprise web applications? Because I wanted to start with ZF3 but I saw this tutorial and it seems good and also U have good
    ZF background so I think U can answer my Question.

    All the best

  4. After seen a lot of docker videos, this is the one that made me build a development environment without trouble. Thanks i will watch all of your videos.

  5. Great to see someone putting the time and effort in doing these!
    Thanks for sharing.

    I would, however, suggest that for the configuration of xdebug, php and apache, we could, instead of sending echoes and search/replace, just share the files themselves in a volume. That way we can easily change the configuration of the container without needing to rebuild another image. This is specially useful for xdebug, cozz then we can simply add a ';' in the xdebug.ini file in front of the 'zend_extension =' line to turn xdebug off/on which makes phpunit and cs fixer run 10x faster (my experience).
    We can also use the same for sharing the composer cache, so that we can run composer inside the container and use the cache that is in the host, preventing redundant downloads cozz the cache will always be empty.

    On a project using just docker (no docker-compose) I usually create a sh file like this:
    #!/usr/bin/env bash

    docker run –rm
    -e PHP_IDE_CONFIG="serverName=$(basename $(pwd))"
    -v $(pwd)/build/php.ini:/usr/local/etc/php/php.ini
    -v $(pwd)/build/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
    -v ~/.cache/composer:/.composer/cache/
    -v $(pwd):/$(basename $(pwd))
    -w /$(basename $(pwd))
    -u $(id -u):$(id -g)
    [email protected]

    Using docker compose, we can use something like this, in the docker-compose.yml file:
    – ../../../:/opt/app
    – ~/.cache/composer:/.composer/cache/ # so we can use the host composer cache
    – ./php.ini:/usr/local/etc/php/php.ini # so we can easily change php config
    – ./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini # so we can easily change xdebug config

Leave a Reply

Your email address will not be published. Required fields are marked *