12

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?

Handsome Nerd
  • 17,114
  • 22
  • 95
  • 173
  • have you tried changing slashes `/` with anti slashes `\ ` ? Since you are on windows ? And even further : have you considered using [`DIRECTORY_SEPARATOR`](http://php.net/manual/en/dir.constants.php) constant to be sure that you are OS independent ? – β.εηοιτ.βε May 31 '15 at 19:44
  • @b.enoit.be Windows accepts both ‍‍`/‍` and `\\` as directory separator. – Handsome Nerd Jun 01 '15 at 12:22
  • On Linux this doesn't work as well. The problem is `__DIR__` which translates to `phar:///var/www/....`. If I use just a full path (`/var/www/...`), then the mounting works fine. – VolenD Jun 02 '15 at 22:09

1 Answers1

2

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');
cweiske
  • 30,033
  • 14
  • 133
  • 194
fjcero
  • 156
  • 2
  • 14