<?php

$phar = __DIR__ . '/../interfaceDistiller.phar';
if(file_exists($phar)) {
    unlink($phar);
}

$phar = new Phar($phar, 0 , 'interfaceDistiller.phar');
$phar->buildFromDirectory(__DIR__ . '/../src/');
$phar->setStub(<<<'STUB'
<?php
Phar::mapPhar('interfaceDistiller.phar');
require 'phar://interfaceDistiller.phar/autoload.php';
call_user_func(
    new com\github\gooh\InterfaceDistiller\Controller\CommandLine(
        new com\github\gooh\InterfaceDistiller\InterfaceDistiller
    ),
    $argv,
    new SplFileObject('php://stdout')
);
__HALT_COMPILER();
STUB
);


<?php

$phar = __DIR__ . '/../interfaceDistiller.phar';
if(file_exists($phar)) {
    unlink($phar);
}

$phar = new Phar($phar, 0 , 'interfaceDistiller.phar');
$phar->buildFromDirectory(__DIR__ . '/../src/');
$phar->setStub(<<<'STUB'
#!/usr/bin/env php
<?php
Phar::mapPhar('interfaceDistiller.phar');
require 'phar://interfaceDistiller.phar/autoload.php';
call_user_func(
    new com\github\gooh\InterfaceDistiller\Controller\CommandLine(
        new com\github\gooh\InterfaceDistiller\InterfaceDistiller
    ),
    $argv,
    new SplFileObject('php://stdout')
);
__HALT_COMPILER();
STUB
);


Allow for self executeable phar so it can be put into */bin
Allow for self executeable phar so it can be put into */bin

Doesn't break cross platform and makes life a little nicer.

See https://github.com/composer/composer/blob/master/src/Composer/Compiler.php#L170