Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PHP 7 with Yii 2.0 from Docker container. (PHP/7.0.0RC-apache)
# FROM Mac (or similar):
vagrant init box-cutter/ubuntu1504-docker
# edit Vagrantfile as needed (see associated Vagrant file here:, then:
vagrant up --provider virtualbox
vagrant ssh
# FROM DOCKER HOST: (Linux / Vagrant / boot2docker / etc)
docker run -it --rm --name php7 -v "$PWD":/var/www/html -p 80:80 php:7-apache
# change ports / volume info above as needed. don't use "--rm" if you want to keep the contianer when stopped.
# switch to container:
docker exec -it php7 /bin/bash
# php pre-reqs:
# ------------
apt-get update
apt-get -y install bzip2 git nano
apt-get -y install libmcrypt-dev
docker-php-ext-install mcrypt mbstring
apt-get -y install libzzip-dev zziplib-bin zlib1g-dev
docker-php-ext-install zip
docker-php-ext-install pdo_mysql
# Yii2
# -----
# install Composer:
curl -sS | php
mv composer.phar /usr/local/bin/composer
# Composer asset plugin which allows managing bower and npm package dependencies
composer global require "fxp/composer-asset-plugin:~1.0.3"
# latest stable Yii2:
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
# ** OR ** #
# development version:
composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-basic basic
# start / restart apache `apachectl graceful` from container
# or restart container `docker restart php7` from Docker host
# then check e.g., from Mac host :
# http://localhost:8888/basic/requirements.php
# all good, commit container from Docker host:
docker commit php7 php7:yii2
# adjust name:tag as desired
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.