Last active
October 30, 2017 12:30
-
-
Save cwhsu1984/1d2a4a36839fede24baa6e4739f3e0a3 to your computer and use it in GitHub Desktop.
php7.1-fpm and xdebug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ubuntu 16.04 | |
sudo apt-get install php-xdebug | |
/etc/php/7.1/fpm/php.ini | |
[xdebug] | |
xdebug.remote_enable=on | |
xdebug.remote_handler=dbgp | |
xdebug.remote_host=localhost | |
xdebug.remote_port=9000 | |
xdebug.remote_log=/var/log/xdebug.log | |
sudo systemctl restart php7.1-fpm | |
open an url on your server and check phpinfo(), make sure you can see | |
"with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans" | |
# skip this if you feel confident to your environment, or you can check this guide | |
# to compile xdebug/debugclient to ensure your php-fpm is configured correctly | |
# https://walty8.com/remotely-debug-php-using-command-line-vim-vdebug-xdebug/ | |
.vimrc | |
Plugin 'joonty/vdebug' | |
let g:vdebug_options = {'break_on_open': 0} | |
let g:vdebug_options = {'server': 'localhost'} | |
let g:vdebug_options = {'port': '9000'} | |
# remote debug need path mapping | |
#let g:vdebug_options = {'path_maps': {'/remote/path/to/webroot': '/local/path/to/webroot'}} | |
vi /var/www/html/index.php | |
# Set a break point by Pressing | |
Press F10 | |
# At this point your editor window will change, your vim probably not supporting python | |
# Start debugging | |
Press F5 | |
# you should see this meesage at the bottom of vim windows | |
Waiting for a connection (Ctrl-C to cancel, this message will self-destruct in 20 seconds...) | |
# Open the page with ?XDEBUG_SESSION_START=1 | |
Open browse with url http://yourwebsite?XDEBUG_SESSION_START=1 | |
# If nothing happen when you press F5 or F10, then your vim probably not support python 2, | |
# check this thread to confirm that https://github.com/joonty/vdebug/issues/101 | |
# launch vim | |
vi | |
# try this command, | |
:python debugger.run() | |
# this message means your vim does not support python | |
E319: Sorry, the command is not available in this version | |
# If this is the case, then do the following steps to change your vim to vim.nox-py2 | |
sudo apt-get install vim-nox vim-nox-py2 | |
sudo update-alternatives --set vi /usr/bin/vim.nox-py2 | |
# open the file to debug again, you should see the Waiting for a connection message now | |
References | |
https://xdebug.org/docs/all | |
https://github.com/joonty/vdebug | |
https://github.com/joonty/vdebug/issues/303 | |
http://www.sromero.org/wiki/linux/servicios/php/vim_debug_basics | |
https://mutelight.org/minimal-guide-to-debugging-php-with-xdebug-and-vim | |
https://gist.github.com/rahilwazir/74c6be0a452f505da8e1 | |
https://github.com/laradock/laradock/issues/102 | |
https://devforgalaxy.github.io/zh/2016/09/14/debug-containerised-php-app-using-xdebug-with-vim-and-vdebug-zh.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment