Try Hack and HHVM

2 minute read

Lately there has been a lot of talk about HHVM and the new programming language Hack. It all looks great, to bad it does not run your code. The HHVM team is doing their very best to make it 100% backwards compatible with PHP. So at the moment there is very few project that can run on HHVM. But that should not stop you from learning all about HHVM and Hack.

If you want to get your hands dirty with HHVM and Hack the easiest way is to use a virtual machine, Vagrant and Puppet. Don’t be alarmed if you haven’t heard of these techniques before. They are built to make your life simpler.

The first thing you got to do is make sure you have VirtualBox installed and then install Vagrant. The second thing you need to do is to clone this repository. It contains scripts (recipes) how the virtual machine should be configured. Open the terminal and go to the unzipped folder (ie /Users/tobias/Desktop/hhvm) and run vagrant up to start the virtual machine. The last thing you need to do is to add a line in your /etc/hosts like:

#/etc/hosts hhvm.local sf.hhvm

You should now go to your browser and type the url http://hhvm.local and see the “Hello Hack!” message. The source of the script is in the source directory (ie /Users/tobias/Desktop/hhvm/source). Edit the file and reload your browser to see the changes. Happy Hacking!

Running Symfony2 project on HHVM

If you want to try running an existing project of yours on HHVM. Uncomment the last part in the Vagrant file and  update the path:

# If you want to run a symfony application uncomment this line and change the path
config.vm.synced_folder "/Users/tobias/Desktop/MyExistingSymfonyProject", "/srv/sf.hhvm/"

If you run vagrant provision you will update the machine and you will be able to go to http://sf.hhvm  in your browser to run your symfony2 project.

Categories: ,


Leave a Comment