Setting a folder in phar does not work

I created the phar of a Symfony2 web application, but I am having problems with cache folders.

I found out that I can mount an external file / folder in phar. This will fix my problem, but I cannot get an example on a PHP site.

I have a phar that contains index.php:

<?php
$configuration = simplexml_load_string(file_get_contents(
Phar::running(false) . '/config.xml'));
?>

Then I turn on .phar with the following code:

<?php
// first set up the association between the abstract config.xml
// and the actual one on disk
Phar::mount('phar://config.xml', '/var/www/$projectname/config.xml');
// now run the application
include 'phar-archive.phar';
?>

All files exist, but I get the following error:

PHP Fatal error: "PharException" exception exception with the message "config.xml is not a file archive, cannot be mounted" in / var / www / $ projectname / index.php: 3

I have already tried relative / absolute paths, changing permissions, but can't make it work. Also, a working example of how I can set the folder in phar will be great!

+4
1

, $projectname ( echo $projectname; Phar::mount). ,

Phar::mount('phar://config.xml', '/var/www/$projectname/config.xml');

to

Phar::mount('phar://config.xml', "/var/www/{$projectname}/config.xml");

, $projectname , .

+1

Source: https://habr.com/ru/post/1531312/


All Articles