dongshan1959 2016-11-27 17:16
浏览 37
已采纳

Nette phar启动文件

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
ette.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
ette.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!

  • 写回答

1条回答 默认 最新

  • doudao2407 2016-11-29 06:08
    关注

    You can't create .phar from Nette downloaded via Composer. It doesn't have some necessary files (e.g. 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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 iOS绕地区网络检测
  • ¥15 python验证码滑块图像识别
  • ¥15 根据背景及设计要求撰写设计报告
  • ¥15 QT6颜色选择对话框显示不完整
  • ¥20 能提供一下思路或者代码吗
  • ¥15 用twincat控制!
  • ¥15 请问一下这个运行结果是怎么来的
  • ¥15 单通道放大电路的工作原理
  • ¥30 YOLO检测微调结果p为1
  • ¥15 DS18B20内部ADC模数转换器