Skip to content

Debug ProcessMaker process triggers

tomolimo edited this page Aug 9, 2019 · 13 revisions

This section will show you how to debug your PHP triggers line by line, like if you were in your preferred development environment. This method is very easy to configure and use.

Install and configuration

Xdebug

  1. Install on the PM server the Xdebug PHP extension (author Derick Rethans) from https://xdebug.org/docs/install (choose the method that fits your operating system and PHP version).
  2. Configure Xdebug extension like following in the PHP configuration file:

[php_xdebug]
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = ip_address_of_your_visual_studio_code
xdebug.remote_port = 9000
xdebug.remote_mode = req
xdebug.remote_autostart = 1
xdebug.auto_trace = off
xdebug.collect_assignments = on
xdebug.collect_return = on
xdebug.collect_vars = on
xdebug.dump_undefined = on

Note: ip_address_of_your_visual_studio_code is the IP address of your machine from which you want to initiate the debug session. It's the machine hosting the Visual Studio Code. Don't use the xdebug.remote_connect_back option as it will get the IP address of the GLPI server, and not the IP address of the VSC machine (if you start your debug session from GLPI).

VSC

  1. Install Visual Studio Code (=VSC) from https://code.visualstudio.com/ on the client machine
  2. Start VSC, and install "PHP Extension Pack" (author Felix Becker) from marketplace
  3. Switch to 'Debug' view
  4. Start a debug session (it will propose you to choose an environment, select PHP), verify that the 'Listen for Xdebug' section is in the 'launch.json' file and is like following:
{
   "version": "0.2.0",
   "configurations": [
      {
         "name": "Listen for Xdebug",
         "type": "php",
         "request": "launch",
         "port": 9000
      },
...
   ]
}   

Debug session

  1. In PM server admin.
  2. In the trigger you want to debug, add a PHP function call to: xdebug_break(); at the place where you want a breakpoint to occur. Save the trigger.
  3. In VSC Explorer, start a debug session using the 'Listen for Xdebug' option.
  4. Disable the breakpoint for 'Everything' which is set by default, it's in the 'Debug' view and in the breakpoint list (bottom left).
  5. In PM serveur admin (or GLPI if you want to debug a trigger used in GLPI) in your browser and start a case of the process you want to debug.
  6. Execute task by task your case until you reach the breakpoint.
  7. Don't forget to comment out the xdebug_break(); function call when you are finished with your debug, otherwise you may get PHP dumps.