For PHP 7.1 FPM (web interface) configuration the file will be at /etc/php/7.1/fpm/conf.d/20-xdebug.ini, and for CLI the file will be at /etc/php/7.1/cli/conf.d/20-xdebug.ini.Īt the least your configuration should contain the following lines: xdebug.remote_enable = 1 If for some reason you need to make changes you can find configuration files at /etc/php/PHP_VERSION/INTERFACE_TYPE/conf.d/20-xdebug.ini (note that PHP_VERSION, and INTERFACE_TYPE are placeholders). The development environment should have all the configurations for debugging. Manually changing Xdebug PHP configuration ![]() The rest is the same as when debugging a web script, add the breakpoint, start listening to debug session, run the command, make debug actions. The serverName value should be taken from your Homestead configuration sites.map property. bash_extra file on provisioning, make changes if needed): export PHP_IDE_CONFIG="serverName=\ You will also need to set two environment variables (it should be automatically set inside. Those aliases expand to the following commands (notice that you might need to provide PHP version with -v option): # enable Xdebug for CLI scripts is not enabled by default (run php -v to see if it's enabled).įor convenience there are two aliases that enable/disable Xdebug: # enable You can make breakpoints conditional to only pause on specific cases. You should see the window with variables, and actions for debugging (e.g., terminate, run, step into, step over, resume program, stop). Reload the page, and the script execution should stop before the breakpoint. Then open the file you want to debug, add a breakpoint on the line of the code to pause execution on (click on a line number in a gutter). Configure the main project directory (on host) to point to the directory on the remote machine (use pwd in Vagrant terminal to find it). Accept to create a new server configuration.įrom PhpStorm preferences ( ⌘,) go to Languages & Frameworks | PHP | Servers, select the newly created server. For easier access you might want to set a keyboard shortcut which executes both commands (e.g., ⌥⇧D).Īfter loading the page (with debug session turned on) if debugging is not configured PhpStorm will throw a prompt with auto-configuration values. After you finished debugging use Run | Stop listening for PHP Debug Connections command to stop debugging session. Use Run | Start listening for PHP Debug Connections command from the menu to start the debugging session. Create (or select) the remote interpreter based on Vagrant. To stop the debugging session you need to use XDEBUG_SESSION_STOP URL parameter, or to delete the cookie.įrom PhpStorm preferences ( ⌘,) go to Languages & Frameworks | PHP. If you don't want to use the browser add-on, you will need to set XDEBUG_SESSION_START=session_name as: URL parameter, POST parameter, or cookie. After enabling load the page you want to debug. Use FireFox add-on, or Chrome extension to enable the debug session of a web page. If you don't want to use Homestead check the documentation of Xdebug for options on how to install it. If you're not using Homestead check the article on how to get started with it. Laravel Homestead ships with Xdebug installed, and configured. ![]() ![]() Manually changing Xdebug PHP configuration.Skip to any of the sections, or continue reading: ![]() This GitHub repository is used in this article. Depending on your OS, or tools used you might need to make small changes to make this work. Keep in mind this article is based on OSX, PhpStorm ( get started guide), Laravel Homestead for development environment. Sooner, or later you will run into a situation where "proper" debug tools are required to find out how your code is executing. The simple var_dump() function can take you a long way in debugging if you need sometimes to check the value of the variable.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |