From the originators of the VVV Project and WP Engine Labs comes an easy to use HHVM and PHP vagrant for developers! (If you need help with any terms in this post we have the Labs glossary in the footer.)

So what is this specific Vagrant’s purpose?

We want as many themes, plugins, and services as possible to work on HHVM and WordPress. To do this, however, we need to provide tools that make this painless for developers to build for and test against HHVM. WordPress running on HHVM is fairly new, so it is incredibly important to remove variables among teams in the development process. Vagrant is clearly the answer to this.

So, with this in mind, “Mercury Vagrant” is a development environment that is meant to get people started on advanced WordPress and HHVM development in an easy way. Vagrant can be a bit intimidating for some newer developers or developers who are in the middle of their learning process. The Labs team decided we would love to democratize the process of using a Vagrant and increase ease of use and adoption. Also, for experienced developers, we want to save them time by giving them a good base to work more advanced configurations from.

And it’s all GPL! So you can contribute back and help make HHVM development workflow easy with this community owned project!

Introducing Mercury Vagrant (HGV)

Included in the Vagrant open source project:

  • An easy to use installation / quick start guide (both video and text)
  • A super easy to use URL testing feature for switching between PHP & HHVM
  • Auto configuration scripts to get you started with all the tools quickly
  • The ability to debug in the Vagrant (WP_debug and other tools)
  • The ability to load test in the Vagrant

PHP and HHVM testing on a single Vagrant

We are big fans of HHVM and hope that Mercury Vagrant will be used to increase compatibility with more of the WordPress ecosystem. However, this Vagrant isn’t just for that. This Vagrant can be used for standard PHP-style development as well!

As an example, once Mercury Vagrant is installed, you can use the following URL to see exactly how HHVM is working: http://hhvm.hgv.dev

But wait! Is it still running okay on PHP? Lets look: http://php.hgv.dev

Or, hey, maybe you want to test PHP with Varnish cache on http://cache.php.hgv.dev

Or to test with varnish and HHVM http://cache.hhvm.hgv.dev

One Vagrant. Both versions. Easy initial testing.

What is this Vagrant not for?

This Vagrant is not meant to be configured to mirror any specific host, including WP Engine itself, but is meant to be universal to all servers / hosts.

This system is not designed with a fall-back from HHVM to PHP. We want people to be able to see where their code breaks, so it runs the systems side by side. This will help people debug and truly get HHVM ready.

It is an Open Source Project!

Mercury Vagrant is an open source project that we will keep working on for the foreseeable future with support from WP Engine Labs. It is fully licensed under GPLv2 just like WordPress core itself. We may update the copyright text before taking a couple of merges as a side note.

Since this is an initial release, if you run into any issues, have any requests, changes, or thoughts, you can file issues right in github for quick responses from the team.

It should be noted:

Also, remember this is a virtual machine which will not be as performant as a server. In particular, HHVM does not like being throttled and uses CPU heavily. So in some cases this throttling of your machine can make HHVM’s performance number look bad. Load testing is to check for stability of your code and not as measure of performance.

This is built on the great ideas that came before it. Jeremy Felt goes into lengths about how VVV would hopefully be forked and expanded per need here:

https://jeremyfelt.com/code/2013/04/08/hi-wordpress-meet-vagrant/

Labs Glossary:

What is Vagrant? (Because, hey, you may not know yet)

“Create and configure lightweight, reproducible, and portable development environments. Run a single command, “vagrant up”, and sit back as Vagrant puts together your complete development environment. Say goodbye to the “works on my machine” excuse as Vagrant creates identical development environments for everyone on your team.”

https://www.vagrantup.com/

This is fantastic because no matter the operating system (OSX, Windows, Linux), your teams can be on the same page. A solo developer can also make sure that as they work with other larger teams that they are on the same page.

What is HHVM:

HHVM is an open-source virtual machine designed for executing programs written in Hack and PHP. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining the development flexibility that PHP provides.

http://hhvm.com/

What is JIT:

In computing, just-in-time compilation (JIT), also known as dynamic translation, is compilation done during execution of a program – at run time – rather than prior to execution.

http://en.wikipedia.org/wiki/Just-in-time_compilation

Or here is an analogy:

PHP5 is an interpreter. That means basically the same as it means when you’re translating from Japanese to German. You look at the original document, and interpret it into the new language, then do it again and again for each sentence. Instead, as you run a JIT’ted program, it takes a block of Japanese, translates it to German, then remembers this translation so the next time you see this paragraph you just use the German copy instead. This way you don’t have to re-interpret lines over and over.

Another option is to just translate the document beforehand (pre-compile). JIT’ing is better for PHP, because you don’t know the nuances of of which paragraph flows into which paragraph beforehand (documents read only top to bottom, but programs jump around a lot). If you JIT something you can use the knowledge of how the document jumps around to make it faster.

What is active / active (multi-master replication):

Multi-master replication is a method of database replication which allows data to be stored by a group of computers, and updated by any member of the group. All members are responsive to client data queries. The multi-master replication system is responsible for propagating the data modifications made by each member to the rest of the group, and resolving any conflicts that might arise between concurrent changes made by different members.

http://en.wikipedia.org/wiki/Multi-master_replication

What is Byte Code:

Bytecode, also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normally numeric addresses) which encode the result of parsing and semantic analysis of things like type, scope, and nesting depths of program objects. They therefore allow much better performance than direct interpretation of source code.

http://en.wikipedia.org/wiki/Bytecode

What is FPM:

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation with some additional features useful for sites of any size, especially busier sites.

http://php-fpm.org/


tomasTomas Puig is the head of Labs for WP Engine. His career started at NASA Ames Research Center where he worked on computer security and web development. Tomas then worked in the digital ad agency industry with firms LEVEL, COG1, Rosetta, and Propane—notable clients included Facebook, New Relic, Kaiser, Cisco, and Google. Projects under his direction have won 4 Gold National ADDYs and several Cannes CLIOs. Tomas loves video games, Legos, and playing with his dog Éowyn.