Devilbox for quick & flexible PHP stack development

Irene Gohtami
Xendit Engineering
Published in
3 min readMay 7, 2021

Are you a PHP developer? Do you build websites, plugins, libraries that live in a LAMP or MEAN stack? If yes, then let me introduce you to Devilbox, the modern version of WampServer or Xampp.

Xendit as a payment gateway has developed many open source payment plugins that are compatible with WooCommerce and Easy Digital Downloads (both are WordPress eCommerce plugins), as well as Magento, OpenCart, Joomla, and Sirclo. Over time, the number of plugins we built will increase, and maintaining all of these wouldn’t be easy.

So, why should we use Devilbox then? In this post, we will cover the basic ideas of this tool & a quick tutorial on how to setup WordPress in just few minutes.

Overview

Devilbox is a dockerized PHP stack that supports all major OS, requires no setup (as everything is pre-configured), and is highly customizable depending on your needs. The main objective of this tool is that it allows developers to setup many environments and quickly switch to different local server during development.

Pros:

  • Easy setup, comes with default configuration (latest stable build of PHP, MySQL, Apache, etc.)
  • Supported in major OS (Mac, Linux, Windows)
  • Compatible with many PHP frameworks (CakePHP, CodeIgniter, Laravel & many more)
  • Compatible with many CMS platforms (WordPress, Magento, PrestaShop, etc.)
  • If you need to deploy your website in an older PHP version, you don’t need to install a specific binary for it, unlike Xampp / WampServer

Cons:

  • Requires docker so more storage capacity is needed as compared to the more lightweight version of Xampp for instance
  • More suitable for developers with many PHP projects who need to switch between environments

Setup your first project

Now that we’ve familiarized ourselves with Devilbox, let’s find out how to configure WordPress in your local environment.

Install Devilbox

git clone https://github.com/cytopia/devilbox
cd devilbox
cp env-example .env

Find your user id and group id

id -u
id -g

Then edit the .env file and set the following variables with your own user & group id, for example:

NEW_UID=1001
NEW_GID=1002

See the official guide for more info.

Setup WordPress

In your Devilbox git directory, enter the PHP container

./shell.sh

Create a new vhost directory, here we are putting our WordPress files under “helloworld”

mkdir helloworld

Download WordPress and create a symlink to “htdocs”

cd helloworld
git clone https://github.com/WordPress/WordPress wordpress.git
ln -s wordpress.git/ htdocs

Create MySQL database

mysql -u root -h 127.0.0.1 -p -e 'CREATE DATABASE wp_helloworld;'

Configure DNS in your etc/hosts or C:\Windows\System32\drivers\etc (Windows)

127.0.0.1 helloworld.loc

And you’re done! All that’s left is to go to your browser at https://helloworld.loc and you should be able to see the WordPress installation page.

WordPress installation page

Finish setting up and your WordPress will be up and running. As developers, if you need to tweak some codes, the project is located at devilbox/data/www/helloworld/htdocs/…. By default, Devilbox will enable the latest version of all dependencies and if you don’t want to use the latest PHP version for instance, simply edit the .env file and uncomment which version you would like to deploy.

.env

Simple and convenient right? WordPress is just one of many CMS that are supported within Devilbox and thanks to it, maintaining all those plugins really saves a lot of time.

--

--