简体   繁体   中英

How to access to external files from Phar archives?

I need to place config file out of phar of my web application. 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. I tried various file path styles without any success. What is wrong with it?

I use box2 to ubild phar files. It take a long time to build the phar file. 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::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:

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

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