This Docker container builds the latest version of PHP 7.0 on Ubuntu as well as all the PHP extensions needed for Laravel 5.1+. It also includes composer and some nice command line apps like vi for debugging/editing files.
I took pieces from Heroku's PHP 7.0 buildpack and a couple other PHP 7.0 Docker containers that I found. I welcome pull requests or suggestions for improvements on the Github Repo.
This container is intended for local development only, and I wouldn't recommend trying to deploy it. My goal with this Dockerfile was to create a way to quickly test whether an existing Laravel app would work in PHP7, and for that, it works well. In a real production environment, I'd recommend using a Docker compose file and individual Docker containers for each service required to run your application (eg: Apache, PHP7, NGINX, etc.).
Note: I'm assuming you've set up Docker and a VM (if necessary). If not, start here.
- Navigate to the root of your Laravel project
- Currently you have to update the /storage folder permissions to 777. This is due to the fact that the docker container mounts the whole volume of your Laravel application.
- Download the latest version of the base PHP7/Laravel Docker container:
docker pull karllhughes/laravel-php-7
- From the root of your Laravel project, run
docker run -it -v $PWD:/www -p 80:80 karllhughes/laravel-php-7
to bring up the container's command line. - From the container's command line, run any of the following commands:
cd /www
to navigate to the web rootapachectl start
(must be run to start Apache)composer install
orcomposer update
php vendor/bin/phpunit
to run unit tests
- View your Laravel project by going to
localhost
or the IP address of your Virtualbox or server that's running Docker.