如何从Phar存档访问外部文件


How to access to external files from Phar archives?

我需要把配置文件从我的web应用程序的phar。我需要安装它。在我的存根文件中,我尝试:

<?php
try {
    Phar::mount('sites/site.php', __DIR__.'/../sites/site.php');
} catch (PharException $e) {
    print_r($e);
};
Phar::mapPhar();
include '../app.phar';
然而,我得到了"Mounting of sites/site.php to D:'(...)'public/../sites/site.php failed"错误信息。我尝试了各种文件路径样式,但没有成功。有什么问题吗?

我使用box2构建phar文件。构建phar文件需要很长时间。有什么办法能让它快一点吗?

错误信息也很模糊。有什么更好的方法吗?

您是否尝试过使用内部phar uri作为挂载点,如:

 Phar::mount('phar://sites/site.php', __DIR__.'/../sites/site.php');

我也不知道问题是否可能是由于sites子目录,你试过了吗:

 Phar::mount('site.php', __DIR__.'/../sites/site.php');