UPDATE (01/15/2020): fixed some typos and started writing part two.
This year for me, is a year to share and what better way to start it than with this amazing tool.
When I took the leap from .Net development to PHP back in ~2011 the easiest way to set-up a local development environment on windows was using WAMP. (Just to be clear, I love GNU/Linux but just the CLI 😅)
By the end of 2017 I discovered DevilBox
Reproducible and identical development environment for all host operating systems with zero configuration requirements.
I've been using it since then daily, it uses docker so you can use on the OS of your choice, as the author describes it:
The Devilbox is a modern and highly customisable dockerized PHP stack supporting full LAMP and MEAN and running on all major platforms. The main goal is to easily switch and combine any version required for local development.
You can choose between Apache
and Nginx
as your web server, Almost any version of PHP
(for those pesky clients that refuse to let go 5.4), MySQL
, Percona
or MariaDB
, PgSQL
, Redis
and finally MongoDB
...
It comes with its own DNS Server so you can easily use URLs for local development.
And the thing I like the most is a 'Email catch-all' so you can send emails from your apps and see them inside the dashboard without running the risk of sending real emails (using postfix of course).
The installation is pretty straightforward, basically:
# Get the Devilbox
$ git clone https://github.com/cytopia/devilbox
# Create docker-compose environment file
$ cd devilbox
$ cp env-example .env
# Edit your .env file to select the versions needed, or just
# start all container
$ docker-compose up
Smallest stack
This is the smallest possible and fully functional stack you can run
Full stack
To better understand what is actually possible have a look at the full example
If you are interested in learning more about it or going deeper into the configurations, just let me know. I would happily write a post or two going in depth about it.
Top comments (22)
Why you waiting man?!! Go and write a deep post about it, It makes the PHP development much easier especially if you want to use different versions, as example I like these new features in 7.4: Arrow Function, Spread Operator and Typed Properties. I'll wait the new post about it from you. Thank you!!!
Sure I'll do, you can even try PHP 8 with it 😁
PHP8?!! What I heard it will be available in 2021?!
Its in active development, and the image is built nightly from it, github.com/devilbox/docker-php-fpm...
This is from the Repo,
I have almost used this for almost two years, its super awesome. If anyone is also intersted in some scripts that helps to install multiple versions of an application, let me know, i am happy to share.
Anyways, thanks for the post.
Hi there, I'm getting this error
for httpd Cannot start service httpd: driver failed programming external connectivity on endpoint devilbox_httpd_1 (020de2a9f4437690626e391e4d7e1475fa65e324f83d1c5882a5791a37c31e4c): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use
Hey Hi, It seems like you already have something using port 80 on your computer you could run
netstat -ant
and look for port 80 and then kill itThanks, man. I will try that. I hope it will work after that.
Does it facilitate only local development? I mean I couldn't find any guide on taking it to production
In the company I work for, we don't have any dockerized production environments, just bare metal servers so we use devilbox only for development.
But I think it would be possible to use it as such, although there are a lot of things installed on those containers other than the bare minimum we need.
I don't know how big of a burden would it be, but most of the stuff is installed on the php-fpm containers, the best alternative I can think of, would be to replace the devilbox image for php-fpm for a custom one.
Was thinking this as well
One of my colleagues told me about Devilbox but I've never looked as I'm learning more in depth Docker and felt it was better to write from scratch. Would love to see more posts about this though, looks really interesting.
I was in that position at the begining, when I started learning about Docker, almost at the same time that I started using DevilBox, it helped me a lot about docker-compose.
Devilbox is pretty cool and easy to work with once you've got it running...
Unfortunately you need to learn a lot about Docker if you need Devilbox to run from a non-standard hard drive location. Even more fun if you have an older CPU and get stuck with Docker Toolbox.
I've got an unfinished guide waiting for final touches, but it was pretty frustrating. Not a lot of useful information about the exact series of steps required to get Docker to correctly mount a new folder and telling Devilbox how to use it.
I'm trying to get PHP debugging to work in devilbox running under vscode but running into an error where its reporting that port 9000 is already in use.
Doing
lsof -n -i -P | grep LISTEN
I get:
node 1726 devilbox 18u IPv6 630515 0t0 TCP *:34357 (LISTEN)
Does anyone have this working with current vscode & docker?
It seems like the devilbox documentation does not reflect current vscode & docker. Does anyone know if someone is working on fixing this?
I fixed the issue about "port 9000 is already in use", just switched to a new port. Looking at the docker-compose file I do see:
PHP_FPM_SERVER_PORT=9000
I am still very interested in hearing about any efforts to get the documentation updated
I love devilbox. Everything's completely awesome. The only thing I can't get to work is: to make the devilbox available through my local network for other devices in this very same network.
To clarify what I mean: let's say my dev machine is a macbook pro. And now I wanted to view the project/site/app I am working on also on my smartphone, tablet, windows laptop etc. What's to be done, if you wanted to access the "project.loc" located on a macbook from your windows laptop which has access to the same local network via wifi?
I'd be very happy, if you could elaborate on this. Also for any pointers.
Thank you very much!
Great article man, please write a deep post about it...!!! Thanks
Thanks its very useful,fast install !