简体   繁体   English

Nette Phar引导文件

[英]Nette phar boot file

I'm trying to create a single-file version of PHP framework Nette 2.4 . 我正在尝试创建PHP框架Nette 2.4的单文件版本。 I create a phar file using this code: 我使用以下代码创建一个phar文件:

<?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 . 因此,将加载单文件版本,但是没有启动文件loader.php Does anyone know where is the mistake? 有人知道错误在哪里吗? Thanks for all the suggestions! 感谢所有的建议!

You can't create .phar from Nette downloaded via Composer. 您无法从通过Composer下载的Nette创建.phar。 It doesn't have some necessary files (eg your Loader.php). 它没有一些必要的文件(例如,Loader.php)。

If you want to create .phar download official .zip from https://nette.org/en/download and create .phar from folder ./Nette . 如果要创建.phar, https://nette.org/en/download下载官方.zip,并从./Nette文件夹中创建./Nette

__ __

BTW you don't need to create .phar yourself, you can find it in the .zip file in folder Nette-minified 顺便说一句,您不需要自己创建.phar,您可以在Nette-minified minified文件夹的.zip文件中找到它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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