【发布时间】:2016-01-09 00:19:36
【问题描述】:
我已经创建了一个 Symfony2 Web 应用程序的 phar,但是我在缓存文件夹方面遇到了一些问题。
我发现我可以 mount 将外部文件/文件夹放入 phar。这将解决我的问题,但我无法让 PHP 站点上的示例正常工作。
我有一个包含 index.php 的 phar:
<?php
$configuration = simplexml_load_string(file_get_contents(
Phar::running(false) . '/config.xml'));
?>
然后我将 .phar 包含在以下代码中:
<?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';
?>
所有文件都存在,但出现以下错误:
PHP 致命错误:在 /var/www/$projectname/index.php:3 中带有消息“config.xml 不是 phar 存档,无法挂载”的未捕获异常“PharException”
我已经尝试了相对/绝对路径,更改了权限,但无法使其正常工作。此外,我如何将文件夹挂载到 phar 中的工作示例会很棒!
【问题讨论】: