Re: doing phar.phar on windows
| From: | Greg Beaver | Date: | Wed, 10 Jun 2009 16:44:50 +0000 |
| Subject: | Re: doing phar.phar on windows | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44225@lists.php.net to get a copy of this message | ||
Pierre Joye wrote:
> On Wed, Jun 10, 2009 at 5:36 PM, Greg Beaver<greg@chiaraquartet.net> wrote:
>
>> Hi,
>>
>> I don't see an obvious way to build the phar.phar on windows.
>>
>> Can someone with knowledge of how configure.js works (i.e. a Pierre)
>> give me a tip on how to tell it to make phar.phar after building
>> Release_TS/php.exe or Debug_TS/php.exe?
>>
>> Otherwise, it would also be easy to provide a simple script that builds
>> the phar.phar, and have the snapshot builder run the script.
>>
>> Which way would be better?
>>
>
> Can you create it from PHP/using a php script?
>
> If yes, we can add it to mkdist.php easily.
Fantastic, in that case, all that needs to be added to mkdist.php is this:
echo "Generating phar.phar\r\n";
$phar = new Phar($path_to_php . '/phar.phar', 0, 'pharcommand');
foreach (new DirectoryIterator($path_to_phar . '/phar') as $file) {
if ($file->isDir() || $file == 'phar.php') continue;
echo 'adding ', $file, "\r\n";
$phar[(string) $file] = file_get_contents($path_to_phar. '/phar/' .
$file);
}
$phar->setSignatureAlgorithm(Phar::SHA1);
$stub = file($path_to_phar . '/phar/phar.php');
unset($stub[0]); // remove hashbang
$phar->setStub(implode('', $stub));
echo "Creating phar.phar.bat\r\n";
file_put_contents($path_to_php . '/phar.phar.bat', 'php phar.phar %1 %2
%3 %4 %5 %6 %7 %8 %9\r\n");
That should do it. The only problem is that the user will need to
adjust the path of phar.phar at install-time, but I don't see any
obvious way around this outside of the win32 installer.
Note that $path_to_php should be the equivalent of C:\php5 and
$path_to_phar should be C:\php5\ext\phar
Greg