HHVM comes with an interactive debugger called hphpd. In case you’re not familiar with the concept, an interactive debugger is a program that lets you control other programs, and inspect their state. You can set it to pause the controlled program at certain points (e.g., when execution enters a specific function, or reaches a specific line of code). You can look at the values of variables during execution and, in some cases, modify them. Interactive debuggers are powerful tools, and they can drastically increase the ease and efficiency of debugging a large, complex program, as compared to the trial-and-error workflow of
hphpd is also a read-eval-print loop (REPL) for PHP and Hack. You can interactively type in PHP and Hack code, in the context of your codebase (so you can use your library functions and so on), to try out small pieces of code.
If you’ve used other interactive debuggers like GDB or LLDB, you’ll find hphpd quite familiar. In fact, you may not even need to read this chapter; you can probably get started just using hphpd’s interactive help command,
In this chapter, we’ll see how to use hphpd to debug scripts and web apps, how to configure it, and how to get the most out of it.
Start hphpd by typing
hhvm -m debug at a shell command line. Instead of executing any code, HHVM will display a welcome message and drop into the debugger prompt:
$ hhvm -m debug Welcome to HipHop Debugger! Type ...