在OS X 10.9 Mavericks上的PHP Xdebug。

时间:2022-09-19 16:30:21

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?

谁有解决方案或变通方法?

7 个解决方案

#1


90  

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
  • 找到带有Xcode的本机Xdebug扩展。
  • Asks php which config file is loaded
  • 请求php配置文件加载。
  • Adds the Xdebug extension path in the config file
  • 在配置文件中添加Xdebug扩展路径。
  • Restarts apache.
  • 重新启动apache。

Compatible with Sierra, El Capitan & Yosemite with the bundeled apache, but untested with MAMP & XAMPP.

与Sierra, El Capitan & Yosemite兼容,使用bundeled apache,但未经MAMP & XAMPP测试。

Before launching the command, make sure Xcode command line tools are installed : xcode-select --install

在启动命令之前,请确保安装了Xcode命令行工具:Xcode -select—install。

#2


36  

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。你有两个简单的选择:

  1. Use the version already available at:

    使用已提供的版本:

    /usr/lib/php/extensions/no-debug-non-zts-2010052/xdebug.so
    
  2. Build your own:

    构建自己的:

    1. 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.

      确保您有Xcode CLI工具:Xcode -select—install将提示您安装CLI工具。安装CLI工具后,应该在/usr/include/php中包含一些内容。

    2. Go to http://xdebug.org/download.php and download the source tarball for the version of Xdebug you want. For example: http://xdebug.org/files/xdebug-2.2.3.tgz.

      访问http://xdebug.org/download.php,并下载您想要的Xdebug版本的源tarball。例如:http://xdebug.org/files/xdebug-2.2.3.tgz。

    3. Extract the tarball and cd into the directory it created. Inside that directory you'll see a README. From here it's:

      将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。现在是模块/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。因此,从上面的(1)或(2)中,可以将这个块添加到php中。php或php-fpm使用的ini:

[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)>

#3


16  

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安装命令了。

sudo pecl install xdebug

#4


15  

If you are using Mac Yosemite 10.10 and none of the above answers solved the problem. Do the following:

如果你使用的是Mac Yosemite 10.10,上面没有一个答案能解决这个问题。执行以下操作:

  1. Open a terminal

    打开一个终端

  2. Execute find /usr/lib/php/extensions -name "xdebug.so" to know the path to the debug library.

    执行查找/usr/lib/php/extension -name“xdebug”。因此,“了解调试库的路径”。

  3. Execute sudo nano /etc/php.ini to open and edit the php.ini file
  4. 执行sudo nano /etc/php.打开和编辑php。ini文件
  5. In php.ini add the following lines at the end

    在php中。在结尾添加以下代码行。

    [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)

(完成后,输入控件+o保存并控制+x以关闭文件)

(Don't forget to replace the value in zend_extension for whatever you got from the first terminal command)

(不要忘记在zend_extension中替换任何来自第一个终端命令的值)

  1. Execute sudo apachectl restart to load the new configuration
  2. 执行sudo apachectl重新启动以加载新配置。
  3. Sit back and relax
  4. 坐下来,放松

#5


2  

For anyone who is facing this issue I had to build autoconf from source. I followed this answer from another * question.

对于任何面临这个问题的人来说,我必须从源代码中构建autoconf。我从另一个*的问题上回答了这个问题。

https://*.com/a/12333230/2272004

https://*.com/a/12333230/2272004

#6


2  

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 / application /Xcode.app/Contents/Developer/ platform/ MacOSX.platform/Developer/SDKs/MacOSX10.9。sdk / usr /包括/usr/include

#7


2  

I had to brew install xdebug and choose for my version of PHP and it worked! For example,

我必须为我的PHP版本安装xdebug并选择它!例如,

brew install homebrew/php/php56-xdebug

For a PHP version 5.6 variant.

对于PHP版本5.6版本。

#1


90  

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
  • 找到带有Xcode的本机Xdebug扩展。
  • Asks php which config file is loaded
  • 请求php配置文件加载。
  • Adds the Xdebug extension path in the config file
  • 在配置文件中添加Xdebug扩展路径。
  • Restarts apache.
  • 重新启动apache。

Compatible with Sierra, El Capitan & Yosemite with the bundeled apache, but untested with MAMP & XAMPP.

与Sierra, El Capitan & Yosemite兼容,使用bundeled apache,但未经MAMP & XAMPP测试。

Before launching the command, make sure Xcode command line tools are installed : xcode-select --install

在启动命令之前,请确保安装了Xcode命令行工具:Xcode -select—install。

#2


36  

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。你有两个简单的选择:

  1. Use the version already available at:

    使用已提供的版本:

    /usr/lib/php/extensions/no-debug-non-zts-2010052/xdebug.so
    
  2. Build your own:

    构建自己的:

    1. 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.

      确保您有Xcode CLI工具:Xcode -select—install将提示您安装CLI工具。安装CLI工具后,应该在/usr/include/php中包含一些内容。

    2. Go to http://xdebug.org/download.php and download the source tarball for the version of Xdebug you want. For example: http://xdebug.org/files/xdebug-2.2.3.tgz.

      访问http://xdebug.org/download.php,并下载您想要的Xdebug版本的源tarball。例如:http://xdebug.org/files/xdebug-2.2.3.tgz。

    3. Extract the tarball and cd into the directory it created. Inside that directory you'll see a README. From here it's:

      将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。现在是模块/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。因此,从上面的(1)或(2)中,可以将这个块添加到php中。php或php-fpm使用的ini:

[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)>

#3


16  

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安装命令了。

sudo pecl install xdebug

#4


15  

If you are using Mac Yosemite 10.10 and none of the above answers solved the problem. Do the following:

如果你使用的是Mac Yosemite 10.10,上面没有一个答案能解决这个问题。执行以下操作:

  1. Open a terminal

    打开一个终端

  2. Execute find /usr/lib/php/extensions -name "xdebug.so" to know the path to the debug library.

    执行查找/usr/lib/php/extension -name“xdebug”。因此,“了解调试库的路径”。

  3. Execute sudo nano /etc/php.ini to open and edit the php.ini file
  4. 执行sudo nano /etc/php.打开和编辑php。ini文件
  5. In php.ini add the following lines at the end

    在php中。在结尾添加以下代码行。

    [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)

(完成后,输入控件+o保存并控制+x以关闭文件)

(Don't forget to replace the value in zend_extension for whatever you got from the first terminal command)

(不要忘记在zend_extension中替换任何来自第一个终端命令的值)

  1. Execute sudo apachectl restart to load the new configuration
  2. 执行sudo apachectl重新启动以加载新配置。
  3. Sit back and relax
  4. 坐下来,放松

#5


2  

For anyone who is facing this issue I had to build autoconf from source. I followed this answer from another * question.

对于任何面临这个问题的人来说,我必须从源代码中构建autoconf。我从另一个*的问题上回答了这个问题。

https://*.com/a/12333230/2272004

https://*.com/a/12333230/2272004

#6


2  

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 / application /Xcode.app/Contents/Developer/ platform/ MacOSX.platform/Developer/SDKs/MacOSX10.9。sdk / usr /包括/usr/include

#7


2  

I had to brew install xdebug and choose for my version of PHP and it worked! For example,

我必须为我的PHP版本安装xdebug并选择它!例如,

brew install homebrew/php/php56-xdebug

For a PHP version 5.6 variant.

对于PHP版本5.6版本。