我在测试继承的Laravel应用时遇到问题。
通常标记为“ public”的文件夹已重命名为“ html”。
该应用程序本身可以正常运行,但是在运行Behat测试时,它仍会查找公用文件夹。我一直在通过仅复制“ html”文件并将其重命名为public来解决该问题,但是我想解决这个问题,以便让其他同事对该应用程序进行测试。
我查看了Behat文档,但找不到。我也用谷歌搜索了一下,但是没有找到解决它的方法。
任何人都知道如何设置此路径,因此无需寻找名为“ public”的文件夹,而是可以将其更改为寻找名为“ html”的文件夹。
我得到的确切错误是
Warning: file_get_contents(/Library/WebServer/Documents/myApp/myApp/public/build/rev-manifest.json): failed to open stream: No such file or directory in /Library/WebServer/Documents/thirdspace-app/thirdspace/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php line 668
因此,上述路径中的公众需要使用html。
该错误中引用的代码如下所示
if ( ! function_exists('elixir'))
{
function elixir($file)
{
static $manifest = null;
if (is_null($manifest))
{
$manifest = json_decode(file_get_contents(public_path().'/build/rev-manifest.json'), true);
}
if (isset($manifest[$file]))
{
return '/build/'.$manifest[$file];
}
throw new InvalidArgumentException("File {$file} not defined in asset manifest.");
}
}
我真的不想更改此设置,因为我认为这会影响应用程序本身。我只想发送测试以寻找html,而不是公开。我真的只是想确保解决方案仅影响测试,而不影响应用程序本身。
这使用了Laravel helper函数public_path()
,该函数将始终返回期望名为的目录的路径public
。
有几种不同的方法可以覆盖它,但这可能是最简单的方法。为了使它在Behat之前运行,请在中定义bootstrap/app.php
:
$app->bind('path.public', function() {
return base_path().'/html';
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句