EDIT: March 2020 – Scotch Box is no longer actively maintained so please take a look at the following post which described how to use Cognac Box which is currently maintained release.
In this series, I’ll demonstrate some of the web development tools I use. Today we’ll cover Scotch Box — a virtual development environment for your local machine.
Many people begin development by working directly on live, production web servers. Sometimes they’ll work in a sub-directory or a different URL. However, there are several drawbacks to this approach.
- Performance: Every update of your files requires them to be sent over the internet, and equally your tests also need to come back over the internet. While each of these is probably only an extra second of latency for each file, it can quickly add up over the lifetime of development.
- Security: Let’s face it, development code isn’t the most secure out of the gate. I recently was developing a custom framework and in the process of writing the code for the display of images, introduced a bug which would dump any file to the browser, even php code or environment variables.
- Debugging: Debugging tools such as Xdebug shouldn’t be installed on production servers as it can accidentally expose sensitive data.
- Connectivity: You must be connected to the internet to develop, so internet connection, no development.
So for most of my projects, I develop first on my laptop. But instead of installing a full LAMP stack on my desktop (where I’ve got a database and web server running full time in the background), I use a Virtual Machine through Oracles Free VirtualBox Hypervisor. And instead of having one virtual machine host multiple projects, which might have different development needs (specific PHP versions, databases, etc), I spin up a new virtual instance for each project. This is made super easy through a tool called Vagrant. As they say:
Development Environments Made Easy
My favorite development stack is Scotch Box — perhaps this is because I love scotch, but more likely because it’s (in their own words): THE PERFECT AND DEAD SIMPLE LAMP/LEMP STACK FOR LOCAL DEVELOPMENT
It’s three simple command line entries and you get access to:
- Ubuntu 16.04.2 LTS (Xenial Xerus) OS
- Apache Web Server
- PHP v7.0
- Databases: MySql, PostgresSQL, MongoDB, SQLite
- NoSQL/Cache: MemCashed, Redis
- Local Email Testing: MailHog
- Python v2.7
- And much more.
As of March 2020 - this tech static is very outdated, for the most recent and long term supported stack, be sure to checkout the Cognac Box (replacement for SoctchBox)
Within PHP it includes tools like Composer, PHPUnit, WP-CLI. Also since this is designed for development PHP Errors are turned on by default. It works with most frameworks outside of the box, with the exception of Laravel which needs just a bit of tweaking. All major CMS are supposed like WordPress, Drupal and Joomla.
And if you want access to more updated versions, such as PHP 7.2 or Ubuntu 17.10.x, you can pay just $15 for their pro version which comes with so much more!
So how to do install it?
- From the command line, go to your desired root directory, such as Documents
- git clone https://github.com/scotch–io/scotch–box my–project
- cd my–project
- vagrant up (learn how to install vagrant)
You can replace “my-project” with whatever you want to name this specific development project.
After you run “vagrant up” it will take several minutes to download the code from the internet. Then you’ll be all set. You can browse http://192.168.33.10/
For shell access SSH to 127.0.0.1:2222 with the username of vagrant, and password of vagrant.
You’re all set.