Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bobmulder's avatar

Configurable config files for application

Hi there, artisans!

I am working on a Laravel application (duhh) which I might use for multiple clients.

This setup requires that config files in the config folder are flexible. I want to change them for each client. I know, things like keys should be put in the .env file, but passing lists or other configs are not suitable for the .env file. I want to pass them right in the config file (or even better, a yaml file...).

My question is; what is the promoted way to make this happen (apart from the .env file)?

Thank you in advance!

Regards, Bob

0 likes
7 replies
sr57's avatar

2 approaches

  • have a small bash script that adapts your .env pr client
  • have a speficif config that you put in config directtory and get via config() function
bobmulder's avatar

Thanks for the suggestions!

I don't get exactly what you mean with the first one.

About the second one, you mean that I could git ignore the specific config file, create a config.example.php which could be cloned? In that way, it is just adapted in the Laravel ecosystem... Sounds good to me, but I don't know if thats the preferred way...

sr57's avatar
sr57
Best Answer
Level 39

All of the configuration files for the Laravel framework are stored in the config directory.

You can add your specific config file et get the data the same way as the others.

Tray2's avatar

Why do you think you need to adapt the .env and a set of configs depending on which client logs in?

Are you trying to build a multi-tenancy application?

martinbean's avatar

@bobmulder I think you’re better off looking into multi-tenancy.

If you’re going to create an instance of this application for each client, then that’s quickly going to get unmanageable as you then have to run migrations on multiple databases, keep multiple instances of Laravel up-to-date, roll out bug fixes to multiple servers, etc.

bobmulder's avatar

Thank you for your suggestions @tray2 and @martinbean.

I think multi tenancy is overkill in this situation. I'd host a separate application for max 3 or 4 clients on multiple domains.

The issue was more about 'how to handle configs in the configs folder when you don't want to commit them, cause they are application specific'. Those settings are too large for environment variables. I wanted to know the best practice.

As @sr57 points out, I can add a config file which gets data the same way as others.

A solution that came up in my mind is using a yaml parser to get configs from a (not committed) yaml file, so I can configure each application I want.

Just to make sure; I am familiar with the concept of multi tenancy, but it would be overkill in this situation.

Thank you for your thoughts guys!

Please or to participate in this conversation.