OS X 10.9 Mavericks 上的 PHP Xdebug
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19579401/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PHP Xdebug on OS X 10.9 Mavericks
提问by greyfox
I'm having issues setting up my PHP development environment on OS X after installing OS X 10.9 Mavericks.
安装 OS X 10.9 Mavericks 后,我在 OS X 上设置 PHP 开发环境时遇到问题。
Here is the command I am using to install.
这是我用来安装的命令。
sudo pecl install xdebug
downloading xdebug-2.2.3.tgz ...
Starting to download xdebug-2.2.3.tgz (250,543 bytes)
.....................................................done: 250,543 bytes
66 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
Anyone have a solution or a workaround?
任何人都有解决方案或解决方法?
回答by Creaforge
The fast copy-paste way
快速复制粘贴方式
sudo sh -c 'echo zend_extension=$(find /usr/lib/php/extensions -name "xdebug.so") >> $(php -qr "echo php_ini_loaded_file();") && apachectl restart'
This command do the following :
此命令执行以下操作:
- Finds the native Xdebug extension that comes with Xcode
- Asks php which config file is loaded
- Adds the Xdebug extension path in the config file
- Restarts apache.
- 查找 Xcode 自带的原生 Xdebug 扩展
- 询问 php 加载了哪个配置文件
- 在配置文件中添加 Xdebug 扩展路径
- 重启apache。
Compatible with Sierra, El Capitan & Yosemite with the bundeled apache, but untested with MAMP & XAMPP.
与带有捆绑的 apache 的 Sierra、El Capitan 和 Yosemite 兼容,但未经 MAMP 和 XAMPP 测试。
Before launching the command, make sure Xcode command line tools are installed : xcode-select --install
在启动命令之前,请确保已安装 Xcode 命令行工具: xcode-select --install
回答by Dmitry Minkovsky
Don't know about using pecl
. Getting Xdebug after an OS X install is pretty straightforward without pecl
. You've got two easy options:
不知道怎么用pecl
。在 OS X 安装后获取 Xdebug 非常简单,无需pecl
. 您有两个简单的选择:
Use the version already available at:
/usr/lib/php/extensions/no-debug-non-zts-2010052/xdebug.so
Build your own:
Make sure you have the Xcode CLI tools:
xcode-select --install
will prompt you to install the CLI tools. With the CLI tools installed, there should be stuff inside/usr/include/php
.Go to http://xdebug.org/download.phpand download the source tarball for the version of Xdebug you want. For example: http://xdebug.org/files/xdebug-2.2.3.tgz.
Extract the tarball and
cd
into the directory it created. Inside that directory you'll see aREADME
. From here it's:$ phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 $ ./configure --enable-xdebug checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed [... output ...] $ make [... output ...]
使用已在以下位置提供的版本:
/usr/lib/php/extensions/no-debug-non-zts-2010052/xdebug.so
建立你自己的:
确保您拥有 Xcode CLI 工具:
xcode-select --install
将提示您安装 CLI 工具。安装 CLI 工具后,里面应该有东西/usr/include/php
。转到http://xdebug.org/download.php并下载您想要的 Xdebug 版本的源代码 tarball。例如:http: //xdebug.org/files/xdebug-2.2.3.tgz。
将 tarball 解压缩
cd
到它创建的目录中。在该目录中,您将看到一个README
. 从这里是:$ phpize Configuring for: PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 $ ./configure --enable-xdebug checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed [... output ...] $ make [... output ...]
Your built xdebug.so
is now at modules/xdebug.so
. The phpize
is critical to do with XCode CLI tools installed, because phpize
sets up the build parameters for your version of PHP.
您的构建xdebug.so
现在位于modules/xdebug.so
。这phpize
对于安装 XCode CLI 工具至关重要,因为phpize
为您的 PHP 版本设置构建参数。
With your xdebug.so
in hand from (1) or (2) above, you can add this block to the php.ini
being used by your php
or php-fpm
:
有了xdebug.so
上面的 (1) 或 (2) 的手,您可以将此块添加到php.ini
您的php
or 使用的对象中php-fpm
:
[Xdebug]
zend_extension=<full_path_to_xdebug.so>
xdebug.remote_enable=1
xdebug.remote_host=<host running PHP (e.g. localhost)>
xdebug.remote_port=<port Xdebug tries to connect to on the host running PHP (default 9000)>
回答by wal5hy
There are two issues here. The first is that you need to install Xcode command line tools with the command:
这里有两个问题。首先是您需要使用以下命令安装 Xcode 命令行工具:
xcode-select --install
This will mean that the files previously not found in /usr/include/php/
will be available.
这意味着以前找不到的文件/usr/include/php/
将可用。
The next step is to install autoconf
in the same way as Ares shows in his answer.
下一步是autoconf
按照 Ares 在他的回答中显示的相同方式进行安装。
I would cd
into your download folder first
我会先cd
进入你的下载文件夹
cd ~/Downloads/
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make
sudo make install
now you can run the pecl install
command
现在你可以运行pecl install
命令
sudo pecl install xdebug
回答by oabarca
If you are using Mac Yosemite 10.10 and none of the above answers solved the problem. Do the following:
如果您使用的是 Mac Yosemite 10.10 并且上述答案均未解决问题。请执行下列操作:
Open a terminal
Execute
find /usr/lib/php/extensions -name "xdebug.so"
to know the path to the debug library.- Execute
sudo nano /etc/php.ini
to open and edit the php.ini file In php.ini add the following lines at the end
[XDebug] zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so" xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000
打开终端
执行
find /usr/lib/php/extensions -name "xdebug.so"
以了解调试库的路径。- 执行
sudo nano /etc/php.ini
打开并编辑php.ini文件 在 php.ini 最后添加以下几行
[XDebug] zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so" xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000
(When finished, type control+o
to save and control+x
to close the file)
(完成后,键入control+o
以保存并control+x
关闭文件)
(Don't forget to replace the value in zend_extension for whatever you got from the first terminal command)
(不要忘记将 zend_extension 中的值替换为您从第一个终端命令获得的任何值)
- Execute
sudo apachectl restart
to load the new configuration - Sit back and relax
- 执行
sudo apachectl restart
加载新配置 - 高枕无忧
回答by tleo
I had to brew install xdebug
and choose for my version of PHP and it worked!
For example,
我不得不brew install xdebug
为我的 PHP 版本选择,它奏效了!例如,
brew install homebrew/php/php56-xdebug
For a PHP version 5.6 variant.
对于 PHP 5.6 版本的变体。
回答by ltzMaxwell
For the issue phpize error,try this will solve your problem: sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/include
对于问题 phpize 错误,试试这将解决您的问题: sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include /usr/包括
回答by greyfox
For anyone who is facing this issue I had to build autoconf from source. I followed this answer from another StackOverflow question.
对于遇到此问题的任何人,我都必须从源代码构建 autoconf。我从另一个 StackOverflow 问题中遵循了这个答案。