简体   繁体   English

如何在open-basedir指令中包含PHAR存档的路径?

[英]How to include paths to PHAR archives in the open-basedir directive?

I'm trying to use composer on my local development machine, and it always fails when trying to copy something from the PHAR archive: 我正在尝试在本地开发计算机上使用composer ,并且在尝试从PHAR存档中复制某些内容时它总是失败:

[ErrorException]
copy(): open_basedir restriction in effect. File(phar://E:/xampp/php/composer/composer.phar/src/Composer/Autoload/ClassLoader.php) is not within the allowed path(s)

E:\\xampp\\php\\composer is included in the open_basedir directive, reading and writing files in that location works fine, only accessing files in the PHAR archive doesn't work. E:\\ xampp \\ php \\ composer包含在open_basedir指令中,在该位置读取和写入文件可以正常工作,仅访问PHAR存档中的文件无效。 I've tried adding the following paths: 我尝试添加以下路径:

E:\xampp\php\composer\composer.phar\src\
phar://E:/xampp/php/composer/
phar://E:/xampp/php/composer/composer.phar/src/
phar://E:/xampp/php/composer/composer.phar/src/Composer/Autoload/

but none of it helps, it's still failing with the same error. 但它都无济于事,它仍然失败,并显示相同的错误。

Is there a special way to include paths to PHAR archives? 是否有一种特殊的方式来包含PHAR档案的路径? Is it possible at all? 有可能吗? Should it be neccessary anway? 应该是必要的吗? Might this have something to do with this bug: https://bugs.php.net/bug.php?id=64634 ? 可能与此错误有关: https : //bugs.php.net/bug.php ?id =64634吗?

My system: Windows 7 x64, XAMPP 1.8.1, Apache 2.4.3, PHP 5.4.7 我的系统:Windows 7 x64,XAMPP 1.8.1,Apache 2.4.3,PHP 5.4.7

Update: Tried the latest stable PHP 5.4.14 too, same problem. 更新:也尝试了最新的稳定PHP 5.4.14,同样的问题。

I managed to reproduce it and the workaround using stream_copy_to_stream seems to work, so I applied that in 566313834af3a49cd3f6b41001f7d8549e0b9c96 and if you run composer self-update it should now work. 我设法重现它,并且使用stream_copy_to_stream的解决方法似乎可行,因此我在566313834af3a49cd3f6b41001f7d8549e0b9c96中应用了该方法,并且如果您运行作曲家自我更新,它现在应该可以工作。

I am not too sure which other parts of composer might be affected by this, but if you still have similar issues feel free to open a bug report on github. 我不太确定这可能会影响作曲家的其他部分,但是如果您仍然遇到类似的问题,请随时在github上打开错误报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM