web publishing magazine

Xdebug with Visual Studio Code

If you work quite often with PHP, you will soon notice that debugging with the functions print_r() and var_dump() is quite difficult and do not always lead to the target. For this reason there is the PHP extension Xdebug. This PHP extension is already integrated into MAMP PRO and you only have to activate it by clicking a checkbox.

Now all that is missing is a nice visual presentation of the data provided by Xdebug. For example, you can use Visual Studio Code (VSC). For this editor there is an excellent extension “PHP Debug” by Felix Becker. To install, simply open the extension view in VSC and search for “PHP Debug”, click on the green “Install” button and your environment is ready.

Now you are not only informed about errors you made during programming, but you can also examine all variables and their values during the runtime of your PHP program by setting breakpoints. Only in this way it is possible to develop websites efficiently and professionally with PHP.

local/remote switch in your PHP code

If you develop your PHP application locally with MAMP PRO and then publish it on your live server, there will be some differences. One difference would be your MySQL access data, such as your user name and login. When you publish a WordPress installation, MAMP PRO automatically takes over these changes for you. But the world is not just WordPress. The following example shows how to define the credentials for your MySQL database to work both locally and remotely:

Of course, this technique is not limited to this example. You can use it whenever you need to.