Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lgersman/4d15f9dae3310005c5b407782a06b79d to your computer and use it in GitHub Desktop.
Save lgersman/4d15f9dae3310005c5b407782a06b79d to your computer and use it in GitHub Desktop.
notes on setup a local wordpress-develop instance for creating a bugfix using vscode and xdebug

contribute to wordpress-develop

@see https://make.wordpress.org/core/handbook/tutorials/trac/submitting-a-patch/

make a new trac ticket (like https://core.trac.wordpress.org/ticket/62407)

setup

enable php debugging

  • copy .env.example into .env and enable line:

    LOCAL_PHP_XDEBUG=true
    
  • add a ./vscode/launch.json :

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "wp-env",
          "type": "php",
          "request": "launch",
          "port": 9003,
          "stopOnEntry": false, // set to true for debugging this launch configuration
          "log": false,         // set to true to get extensive xdebug logs
          "pathMappings": {
            "/var/www": "${workspaceRoot}",
          }
        }
      ]
    }
    
  • append the following lines to ./tools/local-env/php-config.ini and ./tools/local-env/phpunit-config.ini

    xdebug.mode=develop,debug
    xdebug.start_with_request=yes
    
  • restart development environment : npm run env:restart

  • set breakpoint in tests and debug tests : npm run test:php

    • you can even run only selected tests. example usage : npm run test:php -- --filter Tests_Block_Template

    • CAVEAT : not the whole test suite will run successfully when xdebug ist enabled

create pull request

  • fix the code and commit it

  • create a pull request and enter trac ticket url and short description that the pull request does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment