如何在Mac OS X 10.5上不使用PEAR的情况下安装PHPUnit?

时间:2021-08-30 07:18:44

I am having trouble installing PEAR, but I really only want to install PHPUnit. Does anyone have experience doing this?

我在安装PEAR时遇到问题,但我真的只想安装PHPUnit。有没有人有这方面的经验?

5 个解决方案

#1


Install via GIT

You can follow the instructions from the Git README: https://github.com/sebastianbergmann/phpunit/

您可以按照Git自述文件中的说明操作:https://github.com/sebastianbergmann/phpunit/

"git" the files and drop them in your home directory

cd ~ && mkdir phpunit && cd phpunit
git clone git://github.com/sebastianbergmann/phpunit.git
git clone git://github.com/sebastianbergmann/dbunit.git
git clone git://github.com/sebastianbergmann/php-file-iterator.git
git clone git://github.com/sebastianbergmann/php-text-template.git
git clone git://github.com/sebastianbergmann/php-code-coverage.git
git clone git://github.com/sebastianbergmann/php-token-stream.git
git clone git://github.com/sebastianbergmann/php-timer.git
git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone git://github.com/sebastianbergmann/phpunit-selenium.git

setup a personal binary path

cd ~ && mkdir bin
vi ~/.profile
>> export PATH=$HOME/bin:$PATH
>> :wq
source ~/.profile

create the executable

touch ~/bin/phpunit
chmod 755 ~/bin/phpunit

write the executable

#!/usr/bin/env php
<?php

// set main method
define('PHPUnit_MAIN_METHOD','PHPUnit_TextUI_Command::main');

// add phpunit to the include path
$paths = scandir($_ENV['HOME'].'/phpunit');
$includes = array();
foreach($paths as $path){
    if (!preg_match('/^\./', $path)){
        $includes[] = $_ENV['HOME'].'/phpunit/' . $path;
    }
}
set_include_path(implode(PATH_SEPARATOR,$includes).PATH_SEPARATOR.get_include_path());

// set the auto loader
require 'PHPUnit/Autoload.php';

// execute
PHPUnit_TextUI_Command::main();

test the executable

which phpunit
phpunit --version

#2


From the PHPUnit installation guide:

从PHPUnit安装指南:

Although using the PEAR Installer is the only supported way to install PHPUnit, you can install PHPUnit manually. For manual installation, do the following:

虽然使用PEAR安装程序是唯一支持安装PHPUnit的方法,但您可以手动安装PHPUnit。对于手动安装,请执行以下操作:

  1. Download a release archive from http://pear.phpunit.de/get/ and extract it to a directory that is listed in the include_path of your php.ini configuration file.
  2. 从http://pear.phpunit.de/get/下载发布存档,并将其解压缩到php.ini配置文件的include_path中列出的目录。

  3. Prepare the phpunit script:
    1. Rename the phpunit.php script to phpunit.
    2. 将phpunit.php脚本重命名为phpunit。

    3. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).
    4. 将PHP中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。

    5. Copy it to a directory that is in your path and make it executable (chmod +x phpunit).
    6. 将其复制到路径中的目录并使其可执行(chmod + x phpunit)。

  4. 准备phpunit脚本:将phpunit.php脚本重命名为phpunit。将PHP中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。将其复制到路径中的目录并使其可执行(chmod + x phpunit)。

  5. Prepare the PHPUnit/Util/Fileloader.php script:
    1. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).
    2. 将PHP中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。

  6. 准备PHPUnit / Util / Fileloader.php脚本:将其中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。

#3


Andrew, I am wrestling with installing PHPUnit at the moment. Found out that it helps a lot if restart your Webserver after updating the include_path in php.ini. Now looking for the exact location of the PHP command line interpreter (that is how I got here). I'll keep you informed.

安德鲁,我正在努力安装PHPUnit。发现在更新php.ini中的include_path后重新启动Web服务器会有很大帮助。现在寻找PHP命令行解释器的确切位置(这就是我在这里的方式)。有消息通知你。

Sabine

#4


I just installed it today. My steps were as follows:

我今天刚装好了。我的步骤如下:

  • download from /get/ - I used 3.3.9.tgz
  • 从/ get /下载 - 我使用3.3.9.tgz

  • extract all files into the pear directory (pear-phpunit, PHPUnit/, etc...)
  • 将所有文件解压缩到pear目录(pear-phpunit,PHPUnit /等等)

  • change the @php_bin@ to point to my php binary (/usr/bin/php) in the files mentioned above
  • 在上面提到的文件中将@ php_bin @更改为指向我的php二进制文件(/ usr / bin / php)

  • create a symlink from pear-phpunit to /usr/local/bin/phpunit ( ln -s /usr/share/php/pear/pear-phpunit /usr/local/bin/phpunit )
  • 创建一个从pear-phpunit到/ usr / local / bin / phpunit的符号链接(ln -s / usr / share / php / pear / pear-phpunit / usr / local / bin / phpunit)

#5


I recently made a github fork of phpunit that currently works (mostly) without the use of pear. It might work for you.

我最近创建了一个phpunit的github分支,目前可以(大多数情况下)不使用pear。它可能适合你。

#1


Install via GIT

You can follow the instructions from the Git README: https://github.com/sebastianbergmann/phpunit/

您可以按照Git自述文件中的说明操作:https://github.com/sebastianbergmann/phpunit/

"git" the files and drop them in your home directory

cd ~ && mkdir phpunit && cd phpunit
git clone git://github.com/sebastianbergmann/phpunit.git
git clone git://github.com/sebastianbergmann/dbunit.git
git clone git://github.com/sebastianbergmann/php-file-iterator.git
git clone git://github.com/sebastianbergmann/php-text-template.git
git clone git://github.com/sebastianbergmann/php-code-coverage.git
git clone git://github.com/sebastianbergmann/php-token-stream.git
git clone git://github.com/sebastianbergmann/php-timer.git
git clone git://github.com/sebastianbergmann/phpunit-mock-objects.git
git clone git://github.com/sebastianbergmann/phpunit-selenium.git

setup a personal binary path

cd ~ && mkdir bin
vi ~/.profile
>> export PATH=$HOME/bin:$PATH
>> :wq
source ~/.profile

create the executable

touch ~/bin/phpunit
chmod 755 ~/bin/phpunit

write the executable

#!/usr/bin/env php
<?php

// set main method
define('PHPUnit_MAIN_METHOD','PHPUnit_TextUI_Command::main');

// add phpunit to the include path
$paths = scandir($_ENV['HOME'].'/phpunit');
$includes = array();
foreach($paths as $path){
    if (!preg_match('/^\./', $path)){
        $includes[] = $_ENV['HOME'].'/phpunit/' . $path;
    }
}
set_include_path(implode(PATH_SEPARATOR,$includes).PATH_SEPARATOR.get_include_path());

// set the auto loader
require 'PHPUnit/Autoload.php';

// execute
PHPUnit_TextUI_Command::main();

test the executable

which phpunit
phpunit --version

#2


From the PHPUnit installation guide:

从PHPUnit安装指南:

Although using the PEAR Installer is the only supported way to install PHPUnit, you can install PHPUnit manually. For manual installation, do the following:

虽然使用PEAR安装程序是唯一支持安装PHPUnit的方法,但您可以手动安装PHPUnit。对于手动安装,请执行以下操作:

  1. Download a release archive from http://pear.phpunit.de/get/ and extract it to a directory that is listed in the include_path of your php.ini configuration file.
  2. 从http://pear.phpunit.de/get/下载发布存档,并将其解压缩到php.ini配置文件的include_path中列出的目录。

  3. Prepare the phpunit script:
    1. Rename the phpunit.php script to phpunit.
    2. 将phpunit.php脚本重命名为phpunit。

    3. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).
    4. 将PHP中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。

    5. Copy it to a directory that is in your path and make it executable (chmod +x phpunit).
    6. 将其复制到路径中的目录并使其可执行(chmod + x phpunit)。

  4. 准备phpunit脚本:将phpunit.php脚本重命名为phpunit。将PHP中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。将其复制到路径中的目录并使其可执行(chmod + x phpunit)。

  5. Prepare the PHPUnit/Util/Fileloader.php script:
    1. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).
    2. 将PHP中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。

  6. 准备PHPUnit / Util / Fileloader.php脚本:将其中的@ php_bin @字符串替换为PHP命令行解释器的路径(通常为/ usr / bin / php)。

#3


Andrew, I am wrestling with installing PHPUnit at the moment. Found out that it helps a lot if restart your Webserver after updating the include_path in php.ini. Now looking for the exact location of the PHP command line interpreter (that is how I got here). I'll keep you informed.

安德鲁,我正在努力安装PHPUnit。发现在更新php.ini中的include_path后重新启动Web服务器会有很大帮助。现在寻找PHP命令行解释器的确切位置(这就是我在这里的方式)。有消息通知你。

Sabine

#4


I just installed it today. My steps were as follows:

我今天刚装好了。我的步骤如下:

  • download from /get/ - I used 3.3.9.tgz
  • 从/ get /下载 - 我使用3.3.9.tgz

  • extract all files into the pear directory (pear-phpunit, PHPUnit/, etc...)
  • 将所有文件解压缩到pear目录(pear-phpunit,PHPUnit /等等)

  • change the @php_bin@ to point to my php binary (/usr/bin/php) in the files mentioned above
  • 在上面提到的文件中将@ php_bin @更改为指向我的php二进制文件(/ usr / bin / php)

  • create a symlink from pear-phpunit to /usr/local/bin/phpunit ( ln -s /usr/share/php/pear/pear-phpunit /usr/local/bin/phpunit )
  • 创建一个从pear-phpunit到/ usr / local / bin / phpunit的符号链接(ln -s / usr / share / php / pear / pear-phpunit / usr / local / bin / phpunit)

#5


I recently made a github fork of phpunit that currently works (mostly) without the use of pear. It might work for you.

我最近创建了一个phpunit的github分支,目前可以(大多数情况下)不使用pear。它可能适合你。