There is no performance improvement that really makes a difference. If measuring is likely, but not certain, it has some advantage to one side or the other. If you really want to know do a test benchmark. I won’t do it because it’s not worth even being simple to do. It doesn’t matter, it doesn’t change anything in any program.
Note that the way the file is organized, both in one way and the other, and the way that will recover that data can make more difference. A comparison to understand: Which is faster, access the disk or access the memory? It depends on how each access is done. It is possible to make an algorithm so bad in memory that it is slower than accessing the same data on disk. It is an extreme example but it is possible. The moral of the story is that algorithms are more important.
In general in other languages I would say that setting up by a data structure in the code itself could be better by not having the dependency on an external file that can be modified by someone, even disappearing. And it would have the advantage of allowing someone to change settings by external file. But in PHP the settings are already in external file that can be modified.
What I can see differently and this is important is that if you just return a configuration and have them all in a central file (no matter the format and how it is loaded) changes the organization.
Usually I’d keep a central file, but it depends on the case. Having a central file loaded may slow down slightly because it will load settings that it does not need at that time. But this is minimal and won’t do any different. It’s purely for organizational reasons. Imagine having to look for settings throughout the application. But I’m not saying that there can’t be cases where decentralizing is positive, I just can’t see one easily.
Other than that, unless I see an explicit justification, I’d say it’s a matter of style.
But note that the first case can not be considered exactly setting. I have not seen a concrete case but may be just information needed for something punctual. Though the estate calls config
does not mean that it is effectively a configuration like other existing ones. There may be a semantic reason for doing it differently. There may be a need, in the specific case, to make it clear that there needs to be done separately from other configurations.
The
Laravel
has much that!– Wallace Maxters