Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access to external files from Phar archives?

Tags:

php

phar

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?

like image 628
Handsome Nerd Avatar asked May 28 '15 12:05

Handsome Nerd


1 Answers

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');
like image 142
fjcero Avatar answered Sep 30 '22 00:09

fjcero