简体   繁体   English

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

[英]How to access to external files from Phar archives?

I need to place config file out of phar of my web application. 我需要将配置文件放在我的Web应用程序的phar之外。 I need to mount it. 我需要安装它。 In my stub file I tried: 在我的存根文件中,我试过:

<?php
try {
    Phar::mount('sites/site.php', __DIR__.'/../sites/site.php');
} catch (PharException $e) {
    print_r($e);
};
Phar::mapPhar();
include '../app.phar';

however, I got " Mounting of sites/site.php to D:\\(...)\\public/../sites/site.php failed " error message. 但是,我得到“ Mounting of sites/site.php to D:\\(...)\\public/../sites/site.php failed ”错误消息。 I tried various file path styles without any success. 我尝试了各种文件路径样式,没有任何成功。 What is wrong with it? 这有什么问题?

I use box2 to ubild phar files. 我使用box2来ubild phar文件。 It take a long time to build the phar file. 构建phar文件需要很长时间。 Is there any way to make it faster? 有没有办法让它更快?

The error message is also vague. 错误消息也很模糊。 Any way to get better message? 有什么办法可以获得更好的信息

Have you tried to use an internal phar uri as a mounting point like: 您是否尝试使用内部phar uri作为安装点,如:

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

Also I don't know if the problem could be due the sites subdir, did you try: 此外,我不知道问题可能是由于sites subdir,你尝试:

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

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

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