简体   繁体   中英

How to enable Xdebug in phpstorm

UPDATED

I am trying to configure xdebug in PhpStorm. I ran phpinfo() and I could see that xdebug version, IDE key and that it is enabled.

Loaded Configuration File : /etc/php/7.0/cli/php.ini 

However in the php.ini file, there is no [xdebug] section But I found 20-xdebug.ini file in the /etc/php/7.0/cli/conf.d folder. (I assume this is the one I should edit for configuration)

It contains only one line: zend_extension=xdebug.so There is no port number, enable/disable.What is the next step in configuring xdebug?

Usually, configuration files for all extensions are placed in a directory called conf.d .

Also, have a look at rows contained 'Additional .ini files parsed' or 'Scan this dir for additional .ini files'. You can see below how it looks for my environment (a peace of php -i output):

Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => /usr/local/etc/php/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => 
    /usr/local/etc/php/conf.d/docker-php-ext-gd.ini,
    /usr/local/etc/php/conf.d/docker-php-ext-intl.ini,
    /usr/local/etc/php/conf.d/docker-php-ext-mcrypt.ini,
    /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini,
    /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini,
    /usr/local/etc/php/conf.d/docker-php-ext-zip.ini,

Clue 1. Verify that you don't have two versions of PHP running on your system. Sometimes it happens if you install new PHP with a package manager, over existing one shipped with OS.

Clue 2. Restart "brew services restart php56" or apache2(apachectl start/stop)

The Steps I go through to install xdebug :

A. Install xdebug with package manager brew install homebrew/php/php56-xdebug

B. Check the list of loaded ini-files with php --ini

Console output:

Configuration File (php.ini) Path: /usr/local/etc/php/5.6
Loaded Configuration File:         /usr/local/etc/php/5.6/php.ini
Scan for additional .ini files in: /usr/local/etc/php/5.6/conf.d
Additional .ini files parsed:      /usr/local/etc/php/5.6/conf.d/ext-gmagick.ini,
/usr/local/etc/php/5.6/conf.d/ext-igbinary.ini,
/usr/local/etc/php/5.6/conf.d/ext-imagick.ini,
/usr/local/etc/php/5.6/conf.d/ext-intl.ini,
/usr/local/etc/php/5.6/conf.d/ext-ioncubeloader.ini,
/usr/local/etc/php/5.6/conf.d/ext-mailparse.ini,
/usr/local/etc/php/5.6/conf.d/ext-mcrypt.ini,
/usr/local/etc/php/5.6/conf.d/ext-mongo.ini,
/usr/local/etc/php/5.6/conf.d/ext-oauth.ini,
/usr/local/etc/php/5.6/conf.d/ext-opcache.ini,
/usr/local/etc/php/5.6/conf.d/ext-tidy.ini,
/usr/local/etc/php/5.6/conf.d/ext-uploadprogress.ini,
/usr/local/etc/php/5.6/conf.d/ext-xdebug.ini

C. php -m | grep xdebug php -m | grep xdebug - If you have xdebug modules installed, you will see "xdebug" in output.

D. verify "zend_extension=" line that points on xdebug.so. Should be already there if you install with package manager.

E. Check tune settings for xdebug, mine are:

[xdebug] zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"

xdebug.remote_port=9089 // <-- same in IDE
xdebug.default_enable=1
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp
xdebug.idekey=PHPSTORM
xdebug.var_display_max_depth = -1 
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1 
xdebug.max_nesting_level = 1000

F. In PhpStorm set port number to 9089 and select can accept external connections: "X"

Hope it helps. (I'm using mac, but is the same for Linux or Win)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM