laravel 如何在 Lumen 中使用辅助函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41101325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I use helper functions in Lumen?
提问by daninthemix
$credentials = app_path();
Results in:
结果是:
[Symfony\Component\Debug\Exception\FatalThrowableError] Call to undefined function App\LtClasses\app_path()
[Symfony\Component\Debug\Exception\FatalThrowableError] 调用未定义的函数 App\LtClasses\app_path()
But it's listed as a helper here: https://laravel.com/docs/5.3/helpers#method-app-path
但它在这里被列为助手:https: //laravel.com/docs/5.3/helpers#method-app-path
回答by Carlos Fdev
Those are the Laravel docs, you don't have the same helpers available on Lumen, you can have a look at the helpers that the Lumen framework comes with at
这些是 Laravel 文档,您在 Lumen 上没有相同的帮助程序,您可以查看 Lumen 框架附带的帮助程序
/vendor/laravel/lumen-framework/src/helpers.php
/vendor/laravel/lumen-framework/src/helpers.php
Workarounds to achive what you need here could be
实现您在此处所需的解决方法可能是
app()->path();
app('path');
base_path('app');