Run a PHP debugger

This topic discusses how to run a PHP debugger using Xdebug as an example.

Get started

Click to expand/collapse content
  1. Log in to your local development machine, or switch to, the Magento file system owner.
  2. Change to a directory to which the Magento file system owner has write access, such as the web server docroot.
  3. Log in to your project:

    magento-cloud login
  4. List your projects:

    magento-cloud project:list
  5. If necessary, clone a project.

    magento-cloud project:get <project ID>

    Typically, you should clone the project in the web server’s docroot or a Virtual Host docroot.

  6. Change to a project directory.

    For example, cd /var/www/html/magento2

  7. List environments in the project:

    magento-cloud environment:list

    magento-cloud environment:list displays environment hierarchies whereas git branch displays does not. If you have any nested environments, use magento-cloud environment:list.

  8. Fetch origin branches:

    git fetch origin
  9. Check out an environment:

    magento-cloud environment:checkout <environment ID>

    To create a new environment, use magento-cloud environment:branch <environment name> <parent environment ID>

  10. Pull updated code:

    git pull origin <environment ID>
  11. Create a snapshot of the environment.

    magento-cloud snapshot:create -e <environment ID>

Set up Xdebug

Click to expand/collapse content

To set up Xdebug:

  1. Open in a text editor.
  2. In the runtime section, under extensions, add xdebug.

    An example follows:

          - mcrypt
          - redis
          - xsl
          - json
          - xdebug
  3. Save your changes to and exit the text editor.
  4. Add, commit, and push the changes to redeploy the environment:

    git add -A
    git commit -m "Add xdebug"
    git push origin <environment ID>
  5. Get the environment’s SSH URL:

    magento-cloud environment:ssh --pipe -e <environment ID>
  6. To use Xdebug, SSH to the environment as follows:

    ssh -R <xdebug listen port>:<host>:<xdebug listen port> <SSH URL>

    For example,

    ssh -R 9000:localhost:9000