2012年12月11日火曜日

Ubuntu12.04でPHPUnitを使う方法

先日10ヶ月ぶりぐらいにPHPを書く機会がありました.
その時にPHPUnitがスムーズに使用開始できませんでした.解決の手順です.

Ubuntu Server 12.04はapt-getでPHPUnitをインストールすることができますが,実行すると
$ phpunit 
PHP Warning:  require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Fatal error:  require_once(): Failed opening required 'PHP/CodeCoverage/Filter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/bin/phpunit on line 38
このようにエラーになり動作しません.

PEAR経由でPHP_CodeCoverageをインストールしましょう.PHPUnitをapt-getでインストールしたのなら,PEARもその時に一緒にインストールされています.
$ sudo pear channel-discover pear.phpunit.de
$ sudo pear channel-discover components.ez.no
$ sudo pear install phpunit/PHP_CodeCoverage

しかしまだ失敗します.
$ phpunit 
PHP Fatal error:  Call to undefined method PHP_CodeCoverage_Filter::getInstance() in /usr/bin/phpunit on line 39

PHPUnitもPEAR経由でのインストールにします.まずはapt-getでインストールしたPHPUnitをアンインストールします.
$ sudo apt-get remove phpunit

PEARでPHPUnitをインストールします.
$ sudo pear channel-discover pear.symfony-project.com
$ sudo pear channel-discover pear.symfony.com
$ sudo pear install phpunit/PHPUnit
これでPHPUnitが使えるようになります.

ここまで僕が試した順に書きましたが,以下にインストール直後のUbuntu ServerでPHPUnitを使える状態にする手順を記します.


$ sudo apt-get install php-pear
$ sudo pear channel-discover pear.phpunit.de
$ sudo pear channel-discover components.ez.no
$ sudo pear channel-discover pear.symfony-project.com
$ sudo pear channel-discover pear.symfony.com
$ sudo pear install phpunit/PHP_CodeCoverage phpunit/PHPUnit


参考: http://stackoverflow.com/questions/1528717/phpunit-require-once-error

2 件のコメント:

  1. Decongestants reduce the irritation from the mucus walls. Usually when you use these kinds of, nasal over-crowding is usually lessened, improving tips on how to improved nasal paragraphs. Most of these easy to get at passageways are able to much more readily exude excess mucus in addition to infectious dust inside sinus parts, bringing about better in addition to disinfected sinus cavities.Kyäni

    返信削除
  2. Apartments inside Alanya stay fairly cheep, with spite of costs growing significantly. even though your market have been affected by recent financial events, It has proved to be able to become much further robust compared to inside numerous some other countries. because new laws came straight into Force allowing foreigners to help buy land, both involve ALONG WITH fees have increased. Prices, particularly decrease your coast, usually are rising rapidly, AS WELL AS are generally necessary to help carry on to be able to do thus over the next five to help eight years.It doesn't need to make use of an estate agent to search for AS WELL AS buy the Apartment within Alanya. However, a lot of consumers Pick out to be able to do, therefore Just like estate agents cater to the crafted Requirements involving foreigners AND are aware of every one of the legal requirements. previous committing to procuring the Apartment, you\'ll want to transaction whether or not You can find just about any amazing debts to the property. lägenhet i Alanya

    返信削除