How do you install PHPUnit without using PEAR on Mac OS X 10.5?

青春壹個敷衍的年華 提交于 2019-11-30 14:14:00

问题


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


回答1:


Install via GIT

You can follow the instructions from the Git README: 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:

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

  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. Prepare the phpunit script:
    1. Rename the phpunit.php script to phpunit.
    2. Replace the @php_bin@ string in it with the path to your PHP command-line interpreter (usually /usr/bin/php).
    3. Copy it to a directory that is in your path and make it executable (chmod +x phpunit).
  3. 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).



回答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.

Sabine




回答4:


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

  • download from /get/ - I used 3.3.9.tgz
  • extract all files into the pear directory (pear-phpunit, PHPUnit/, etc...)
  • change the @php_bin@ to point to my php binary (/usr/bin/php) in the files mentioned above
  • create a symlink from pear-phpunit to /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.



来源:https://stackoverflow.com/questions/628986/how-do-you-install-phpunit-without-using-pear-on-mac-os-x-10-5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!