Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

How to create an environment-aware configuration in Laravel 11?

$
0
0

I'm working on a Laravel 11 project and I need to set up environment-aware configurations that is accessible with config method. For example, I have a constant.php file in the config directory for general configurations, and a constant.php file in the config/production directory for production-specific configurations.

Here's the directory structure:

config/    constant.phpconfig/production/    constant.php

I want to achieve the following:

config('constant')

On local and staging environments, load only the config/constant.php.

On production environment, load both config/constant.php and config/production/constant.php, with config/production/constant.php overriding any overlapping configurations from config/constant.php.

How can I configure Laravel 11 to achieve this environment-aware configuration loading?

Code samples or any specific methods would be greatly appreciated!

Additional context:

I'm familiar with Laravel's env() function and configuration caching, but I'm not sure how to implement this selective configuration loading based on the environment.


Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>