Welcome Guest, Not a member yet? Register   Sign In
The Config namespace is pointless and merciless.
#1

I want to make a reservation right away that I did not conduct in-depth research on this issue.
I also want to note that I'm not a fan of the fact that the framework began to use classes as a configuration, not arrays.

What is the point of this thread.

The Autoload config makes it possible to define namespaces. In particular, the Config namespace is already defined and can in fact be changed.
At least that's how it was intended, I suppose.
PHP Code:
    public $psr4 = [
        APP_NAMESPACE => APPPATH// For custom app namespace
        'Config'      => APPPATH 'Config',
    ]; 

BUT WE CAN'T CHANGE IT!

Fragment of bootstrap.php file

PHP Code:
if (! class_exists(Autoload::class, false)) {
    require_once SYSTEMPATH 'Config/AutoloadConfig.php';
    require_once APPPATH 'Config/Autoload.php';
    require_once SYSTEMPATH 'Modules/Modules.php';
    require_once APPPATH 'Config/Modules.php';


As you can see, the loader is trying to include files in a different path. APPPATH . 'Config/
That is, if a developer suddenly wants to move the configs to another directory and even changes the path in the Autoload class, he will get errors, if only because the Autoload class itself will not be loaded.

But it's not just in bootstrap.php. The static path is specified in all places of work with configs.


It's the same with the namespace.

Many classes depend on configurations located in the Config namespace or use Config\Services::class.
By changing the namespace of the config, we again get a broken application.


I think that the situation with modules is exactly the same. All module configs must be located in the Config directory.


That is, in fact, we have not just a framework, but a framework with an integrated application.
Therefore, for tests, we need an application in the repository. If you look at laravel/framework you won't see the "app" directory nor the tests associated with the application.


My opinion.

At this stage, this is not possible, but it is quite possible in version 5.0

Refuse to test the framework through the application. That is, the framework classes should get rid of this dependency.
Stop believing that configs in the form of classes are a killer feature and accept the reality that arrays are the best for configs.
If we use arrays and take out the config directory from the application, then we will reduce the dependence between the application, the framework and the configs themselves.
I think that Symfony, Laravel and Yii developers can't go wrong with this approach.

Regarding configs of modules. They can be placed in the application's config directory using the Publisher.
Reply


Messages In This Thread
The Config namespace is pointless and merciless. - by iRedds - 03-09-2023, 07:54 PM



Theme © iAndrew 2016 - Forum software by © MyBB