简体   繁体   中英

Nette phar boot file

I'm trying to create a single-file version of PHP framework Nette 2.4 . I create a phar file using this code:

<?php
$phar = new Phar('nette.phar');
$phar->buildFromDirectory(__DIR__ . '/../vendor/nette');
$phar->setStub("<?php
    require 'phar://' . __FILE__ . '/loader.php';
    __HALT_COMPILER();");
$phar->compressFiles(Phar::GZ);

Everything is fine, the file is created. If I try to use this compacted version:

// bootstrap.php
<?php
require __DIR__ . '/nette.phar';
...

Error occurs:

Warning: require(phar://C:\wamp64\www\app\nette.phar/loader.php): failed to open stream: phar error: &quot;loader.php&quot; is not a file in phar &quot;C:/wamp64/www/app/nette.phar&quot; in C:\wamp64\www\app\nette.phar on line 2

So, single-file version is loaded, but there is no boot file loader.php . Does anyone know where is the mistake? Thanks for all the suggestions!

You can't create .phar from Nette downloaded via Composer. It doesn't have some necessary files (eg your Loader.php).

If you want to create .phar download official .zip from https://nette.org/en/download and create .phar from folder ./Nette .

__

BTW you don't need to create .phar yourself, you can find it in the .zip file in folder Nette-minified

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM