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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:54:40  来源:igfitidea点击:

How do I use helper functions in Lumen?

laravellumen

提问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');