简体   繁体   English

如何在phpstorm中启用Xdebug

[英]How to enable Xdebug in phpstorm

UPDATED 更新

I am trying to configure xdebug in PhpStorm. 我正在尝试在PhpStorm中配置xdebug。 I ran phpinfo() and I could see that xdebug version, IDE key and that it is enabled. 我运行了phpinfo() ,我看到了xdebug版本,IDE密钥并启用了它。

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. 但是,在php.ini文件中没有[xdebug]部分,但是我在/etc/php/7.0/cli/conf.d文件夹中找到了20-xdebug.ini文件。 (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? 它仅包含一行: zend_extension=xdebug.so没有端口号,启用/禁用。配置xdebug的下一步是什么?

Usually, configuration files for all extensions are placed in a directory called conf.d . 通常,所有扩展名的配置文件都放在一个名为conf.d的目录中。

Also, have a look at rows contained 'Additional .ini files parsed' or 'Scan this dir for additional .ini files'. 另外,查看包含“已解析其他.ini文件”或“在此目录中扫描其他.ini文件”的行。 You can see below how it looks for my environment (a peace of php -i output): 您可以在下面看到它对我的环境的外观( php -i输出和平):

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. 提示1.确认您的系统上没有运行两个版本的PHP。 Sometimes it happens if you install new PHP with a package manager, over existing one shipped with OS. 有时,如果您使用软件包管理器安装新的PHP,而不是操作系统附带的现有PHP,则会发生这种情况。

Clue 2. Restart "brew services restart php56" or apache2(apachectl start/stop) 提示2.重新启动“ brew服务,重新启动php56”或apache2(apachectl启动/停止)

The Steps I go through to install xdebug : 我安装xdebug的步骤:

A. Install xdebug with package manager brew install homebrew/php/php56-xdebug A.使用软件包管理器brew install homebrew/php/php56-xdebug安装xdebug brew install homebrew/php/php56-xdebug

B. Check the list of loaded ini-files with php --ini B.php --ini检查已加载的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 C. php -m | grep xdebug php -m | grep xdebug - If you have xdebug modules installed, you will see "xdebug" in output. php -m | grep xdebug如果安装了xdebug模块,则输出中将显示“ xdebug”。

D. verify "zend_extension=" line that points on xdebug.so. D.验证指向xdebug.so的“ zend_extension =“行。 Should be already there if you install with package manager. 如果使用软件包管理器安装,应该已经存在。

E. Check tune settings for xdebug, mine are: E.检查xdebug的调整设置,我的是:

[xdebug] zend_extension="/usr/local/opt/php56-xdebug/xdebug.so" [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" F.在PhpStorm中,将端口号设置为9089,然后选择接受外部连接:“ X”

Hope it helps. 希望能帮助到你。 (I'm using mac, but is the same for Linux or Win) (我使用的是Mac,但对于Linux或Win来说都是相同的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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