Phar

Sebastian Bergmann » 27 June 2008 » in PHPUnit » 6 Comments

I took Derick's blog posting on Phar as an incentive to finally experiment with it myself.

<?php
$phar = new Phar('phpunit-3.3-svn.phar', 0, 'phpunit-3.3-svn.phar');
$phar->buildFromDirectory('/usr/local/src/phpunit/release/3.3', '/\.php$/');
 
$stub = <<<ENDSTUB
#! /usr/local/php-5.3/bin/php
<?php
Phar::mapPhar('phpunit-3.3-svn.phar');
require 'phar://phpunit-3.3-svn.phar/PHPUnit/TextUI/Command.php';
__HALT_COMPILER();
ENDSTUB;
 
$phar->setStub($stub);
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
?>

Running the script above will create a phpunit-3.3-svn.phar Phar archive that contains the complete PHPUnit distribution.

Furthermore, you can directly invoke the PHPUnit command-line test runner by execution the Phar archive.

Defined tags for this entry: , ,

Trackback specific URI for this entry

6 Comments to "Phar"

Display comments as (Linear | Threaded)
  1. Borek
    28/06/2008 at 11:03 Permalink
    This is excellent news, I'm really looking forward to the 3.3 release.

    Reply

  2. Pierre
    28/06/2008 at 11:48 Permalink
    If I understand correctly, this would be a very cool way to include vendor / 3rd-party libraries into your own application, without using svn:externals which sometimes really sucks (e.g. if the externals provider website is down).

    Reply

  3. Sebastian Bergmann
    28/06/2008 at 11:49 Permalink
    At least that is what I commonly see in Java projects that just bundle JARs of their dependencies.

    Reply

  4. Stefan Priebsch
    28/06/2008 at 12:17 Permalink
    It seems like this will enable us to put PHPUnit under version control with the source code, and thus make sure that the tests are always run against this PHPUnit version in the future, leaving out the possibility of test regressions just because they are run in a different environment. This is so cool, and one of the main reasons why I am eagerly waiting for PHP 5.3 and Phar.

    Reply

  5. Sebastian Bergmann
    28/06/2008 at 12:20 Permalink
    You can, of course, also use svn:externals to get PHPUnit under your own revision control.

    Reply

  6. Pierre
    28/06/2008 at 15:21 Permalink
    If SVN is not your favourite VCS, you can't.

    Reply

0 Trackbacks to "Phar"

  1. No Trackbacks

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Submitted comments will be subject to moderation before being displayed.