To make things easier, this is using Crane to orchestrate the Docker containers.
The environment consists of 3 containers: the sample app (with PHP and Composer installed), a server (Nginx + php-fpm), and a MySQL database (accessible from your app via DB_PORT
; see crane.json
for user/password). The app and server containers are based on michaelsauter/php-base.
Docker and Crane. If you're on OS X and have no Docker environment setup yet, I recommend docker-osx. boot2docker is nice, but unfortunately, it does not support bind-mounting volumes yet so it can't be used for this example.
git clone [email protected]:michaelsauter/silex-crane-env.git
cd silex-crane-env
crane lift
That will build the images and run the containers. Note that on the first run, the server container will need to install the dependencies, so even after the containers are started, the app cannot be accessed until composer install
finishes. Use docker logs -f silex_server
to see the progress. After the autoload files are generated, try localhost/hello/world
. As the app container bind-mounts app/silex
, you can edit e.g. app/silex/web/index.php
and see the changes take effect immediately.