Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XDebug Debugging Guide #59

Open
Silic0nS0ldier opened this issue Nov 10, 2018 · 4 comments
Open

XDebug Debugging Guide #59

Silic0nS0ldier opened this issue Nov 10, 2018 · 4 comments
Assignees
Labels
Docker Anything Docker related New guide request New guide, section or recipe up-for-grabs Not assigned yet Vagrant Anything Vagrant related

Comments

@Silic0nS0ldier
Copy link
Member

Silic0nS0ldier commented Nov 10, 2018

This is more of a reminder for me then anything else.

I got XDebug working the other day, and the debugging experience is significantly better compared to unassisted techniques like manually logging to a file. Some setup is required, but its fairly easy for basic stacks. Given some modifications to the docker-compose.yml and php Dockerfile files it should be even easier to setup under Docker.

@Silic0nS0ldier Silic0nS0ldier self-assigned this Nov 10, 2018
@Silic0nS0ldier Silic0nS0ldier added the Doc improvement Something in the doc requires more precision and details label Nov 10, 2018
@lcharette
Copy link
Member

I should have kept the setup steps on Homestead. I could add Homestead setup once you’ve done the Docker one.

@lcharette lcharette added Docker Anything Docker related New guide request New guide, section or recipe up-for-grabs Not assigned yet Vagrant Anything Vagrant related and removed Doc improvement Something in the doc requires more precision and details labels May 25, 2019
@lcharette
Copy link
Member

Also need to note debug is required to generate coverage report locally...

Here's some notes I have laying around:


Homestead

https://edcs.me/blog/setting-up-xdebug-with-phpstorm-and-laravel-homestead/

    sudo su
    apt-get install php-xdebug
    nano /etc/php/7.2/fpm/conf.d/20-xdebug.ini
    zend_extension=xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_connect_back = 1
    xdebug.remote_port = 9000
    xdebug.max_nesting_level = 250
    nano /etc/php/7.2/cli/conf.d/20-xdebug.ini
    service php7.2-fpm restart
    php -i | grep "xdebug support"

MacOS Mojave

    vendor/bin/phpunit --coverage-html _meta/coverage
    Error:         No code coverage driver is available

https://xdebug.org/docs/install

Install Pear and Pecl :

https://jason.pureconcepts.net/2012/10/install-pear-pecl-mac-os-x/

    curl -O https://pear.php.net/go-pear.phar
    sudo php -d detect_unicode=0 go-pear.phar

You should now be at a prompt to configure PEAR.

  1. Type 1 and press return.
  2. Enter: /usr/local/pear
  3. Type 4 and press return.
  4. Enter: /usr/local/bin
  5. Press return
    pear version

Autoconf :

    curl http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz > autoconf.tar.gz
    tar -xvzf autoconf.tar.gz
    cd autoconf-2.69
    ./configure
    sudo make && sudo make install
    export PHP_AUTOCONF=/usr/local/bin/autoconf

Install Headers Files :

    sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Xdebug :

    sudo pecl install xdebug
    
    sudo mkdir -p /usr/local/php/extensions
    
    sudo cp /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so /usr/local/php/extensions
    
    sudo nano /etc/php.ini
    [xdebug]
    zend_extension=/usr/local/php/extensions/xdebug.so
    xdebug.remote_enable=on
    xdebug.remote_log="/var/log/xdebug.log"
    xdebug.remote_host=localhost
    xdebug.remote_handler=dbgp
    xdebug.remote_port=9000
    sudo apachectl restart
    php -i | grep "xdebug support"

Atom XDebug

https://medium.com/vehikl-news/remote-php-debugging-with-xdebug-atom-and-homestead-a6db258cfa6a

Safari : https://itunes.apple.com/ca/app/safari-xdebug-toggle/id1437227804?l=fr&mt=12
Chrome : https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en

Vagrant box:

    ports:
    - send: 9999
      to: 9000
    vagrant reload --provision
    vagrant ssh
    sudo nano /etc/php/7.2/fpm/conf.d/20-xdebug.ini

Make sure it contains :

    xdebug.remote_enable = 1
    xdebug.remote_connect_back = 1

If any changes :

    sudo service php7.2-fpm restart

In Atom, install php-debug

@Silic0nS0ldier
Copy link
Member Author

Built in lando support coming in 4.5 simplifies things somewhat, but integrating IDEs with XDebug remains a pain point. I'm of the mind we should try and get some guides together for common IDEs (VS Code, PHPStorm) and OS (since they impact how things are setup in some circumstances).

This would be for XDebug v3, which thankfully is easier to get working.

@lcharette
Copy link
Member

IDE might be out of scope of UF, unlike our Docker/Lando/Homestead integration. Maybe a link to an external guide could be enough.

This would be for XDebug v3, which thankfully is easier to get working.

Meh, depend on the OS... Looking at you Big Sur...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docker Anything Docker related New guide request New guide, section or recipe up-for-grabs Not assigned yet Vagrant Anything Vagrant related
Projects
None yet
Development

No branches or pull requests

2 participants