【发布时间】:2016-03-21 18:04:35
【问题描述】:
我的问题是关于createDefaultStub 的$indexfile 和$webindexfile。我的理解是,如果请求来自 cli,$indexfile 将被提供,$webindexfile 将通过浏览器请求提供。
我从任何一个来源都得到了相同的响应(“后端”),我误解了这种行为吗?还是我的实现有误?
谢谢!
目录树:
PHAR
+--app
+--backend
+--index.php //prints 'backend'
+--frontend
+--index.php //prints 'frontend'
+--build //destination for PHAR
+--build.php
+--index.php
/build.php
$phar = new Phar("build/app.phar", 0, "app.phar");
$phar->buildFromDirectory("./app");
$phar->setStub(
$phar->createDefaultStub(
"backend/index.php", "frontend/index.php"
)
);
/index.php
include('phar://./build/app.phar');
来自 PHP 手册:
createDefaultStub ([ string $indexfile [, string $webindexfile ]] )
【问题讨论】:
-
如果您喜欢冒险,可以查看the contents of the stub。您应该能够使用它来确定哪个条件失败,以及为什么您的网络索引没有被提供。