简体   繁体   English

使用 phar 流的 require 文件在 ZendStudio 中不起作用

[英]require file using phar stream does not work within ZendStudio

I am struggeling with a quite strange problem within ZendStudio.我在 ZendStudio 中遇到了一个很奇怪的问题。 Including or requiring files inside a phar archive using the phar extensions phar:// stream wrapper will not work from within ZendStudio.使用 phar 扩展 phar:// 流包装器在 phar 档案中包含或要求文件在 ZendStudio 中不起作用。

Here is what I have done.这是我所做的。

Given the following file structure:给定以下文件结构:

phar/Test.php
pharbuilder.php
usephar.php

With the following content:内容如下:

phar/Test.php: phar/Test.php:

class Test {}

pharbuilder.php:制药商.php:

$phar = new Phar(__DIR__ . '/test.phar');
$phar->buildFromDirectory(__DIR__ . '/phar/');

usephar.php: usephar.php:

var_dump(file_exists('phar://' . __DIR__ . '/test.phar/Test.php'));
include('phar://' . __DIR__ . '/test.phar/Test.php');
$test = new Test();
var_dump($test);

Now, if you first run the pharbuilder.php in ZendStudio (ZS 8: right click on file, run as PHP Script) the phar file (test.phar) will be successfully created (before running it, you have to add the ini option phar.readonly=0 to the corresponding php.ini).现在,如果您首先在 ZendStudio 中运行 pharbuilder.php(ZS 8:右键单击文件,以 PHP 脚本运行),将成功创建 phar 文件(test.phar)(在运行它之前,您必须添加 ini 选项phar.readonly=0到相应的 php.ini)。 However, running the usephar.php inside ZS, will result in an error.但是,在 ZS 中运行 usephar.php 会导致错误。

bool(true)
Warning: include(): Failed opening 'phar:///somepath/test.phar/Test.php' for inclusion

So obviously, the file can be found, but it cannot be included.所以很明显,文件可以找到,但不能包含。 I can also access the content of the Test.php within the file using file_get_contents('phar://' . __DIR__ . '/test.phar/Test.php')我还可以使用file_get_contents('phar://' . __DIR__ . '/test.phar/Test.php')访问文件中 Test.php 的内容

Also, I noticed that this will not happen, if I modify the run configuration for this script and disable the checkbox "Display debug information when running".另外,我注意到如果我修改此脚本的运行配置并禁用“运行时显示调试信息”复选框,则不会发生这种情况。 So I assume it has something to do with the ZendDebugger, but I'm not quite sure.所以我认为它与 ZendDebugger 有关,但我不太确定。

When I run the same scripts from a console, everything works just fine.当我从控制台运行相同的脚本时,一切正常。

I tried this with ZendStudio 8 and 10 and with all in ZS provided php versions (5.4.11, 5.3.21, 5.3.3 all in CGI and CLI).我在 ZendStudio 8 和 10 以及 ZS 提供的所有 php 版本(5.4.11、5.3.21、5.3.3 都在 CGI 和 CLI 中)进行了尝试。

Since I could not find anybody else with the same problem, I assume that I am doing something wrong and am open to any suggestions.由于我找不到其他有同样问题的人,我认为我做错了什么并且愿意接受任何建议。 Maybe some secret php.ini directive or something like this.也许一些秘密的 php.ini 指令或类似的东西。

This issue is now fixed in Zend Studio 10.6.2.此问题现已在Zend Studio 10.6.2 中修复。 Please mind that as mentioned above you need to modify php.ini file (located in - <studio_home>/plugins/com.zend.php.debug.debugger.win32.x86_\\resources\\php ) and add phar.readonly=0请注意,如上所述,您需要修改php.ini文件(位于 - <studio_home>/plugins/com.zend.php.debug.debugger.win32.x86_\\resources\\php )并添加phar.readonly=0

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

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