laravel Lumen php artisan config:找不到缓存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34579725/
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 12:57:44  来源:igfitidea点击:

Lumen php artisan config:cache not found

laravelcachingconfigartisanlumen

提问by Ahmed Al Bermawy

I'm trying out the PHP micro Framework Lumen (from laravel). When I set up Lumen and I try to use the php artisan config:cachecommand like in Laravel, I get this error :

我正在尝试 PHP 微型框架 Lumen(来自 laravel)。当我设置 Lumen 并尝试使用php artisan config:cacheLaravel 中的命令时,出现此错误:

[InvalidArgumentException]
There are no commands defined in the "config" namespace.

[InvalidArgumentException]
在“config”命名空间中没有定义命令。

So I have problem when I try to deploy the files to server, so I have to change .envfile to change the database username and password.

所以当我尝试将文件部署到服务器时遇到问题,所以我必须更改.env文件以更改数据库用户名和密码。

This makes me think configis not available in artisan

这让我觉得config在工匠中不可用

How can I add it to artisan ?

我怎样才能将它添加到工匠?

回答by Elisha Senoo

Yes, you can not use the php artisan config:cache with your Lumen project, because it is not available out of the box.

是的,您不能在 Lumen 项目中使用 php artisan config:cache,因为它不是开箱即用的。

You can add it by adding this package (orumad/lumen-config-cache)to your project:

您可以通过将此包 (orumad/lumen-config-cache) 添加到您的项目中来添加它:

composer require orumad/lumen-config-cache

回答by Vasu Kuncham

In lumenyou have to add this configuration in bootstrap/app.phpfile

lumen你必须在bootstrap/app.php文件中添加这个配置

$app->configure('custom_config_file_name');

#example
$app->configure('custom_emails');

Then you can access like below:

然后你可以像下面这样访问:

config('filename.key_name');

#example
config('constants.email');