9

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:cache command like in Laravel, I get this error :

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

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

This makes me think config is not available in artisan

How can I add it to artisan ?

Elisha Senoo
  • 3,489
  • 2
  • 22
  • 29
Ahmed Bermawy
  • 2,290
  • 4
  • 35
  • 42

3 Answers3

4

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

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

composer require orumad/lumen-config-cache
Elisha Senoo
  • 3,489
  • 2
  • 22
  • 29
  • may be i will check it later :) – Ahmed Bermawy Sep 07 '18 at 09:56
  • How do you mean? What specific error do you see? You can try other similar projects like this https://packagist.org/packages/niellles/lumen-commands – Elisha Senoo Feb 12 '19 at 17:44
  • This package is not a replacement for `php artisan config:cache` it is useless if the config files are not written and used by you because it provides extra custom functions for getting the information.NOT VERY USEFUL THEREFORE! – Steve Moretz Oct 18 '21 at 11:03
3

In lumen you have to add this configuration in bootstrap/app.php file

$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');
Vasu Kuncham
  • 528
  • 3
  • 14
  • 1
    I think this is not relevant to the question... he is asking about caching the config, not where to get the config value... – Richard Fu Apr 16 '19 at 00:52
  • 1
    I think it's relevant, although a further explanation is needed. Vasu should explain that you usually do not use artisan config:cache, but what he is explaning, and that is why it is not available out of the box. For me, this answer is the correct way to use configurations with Lumen. – vicenteherrera Jul 02 '19 at 08:08
  • This gives me `Target class [config] does not exist.` – f7n Jul 13 '21 at 13:31
  • Thank you very much. This solved my issue with missing config:cache command. – MoDzeus Dec 05 '22 at 11:58
0

Lumen no need to config:cache.

You do not need to do anything after change ‍‍.env

Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144