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

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',


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.

(03-09-2023, 07:54 PM)iRedds Wrote: 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',

No, we cannot change the namespace Config.
We can change the App namespace only.

@kenjis Then why is this namespace added to the application config?

I am not sure, but it has been in the Config file for quite some time now.

Config\Services are the service locator, and you cannot change the namespace for sure.
It is a static class name.

It might be possible to change the location of Config to something other than app/Config.
I don't see the need to change it at all, though.

We cannot change the Config namespace, and even if we change the app folder name,
the following line will not change. So it seems better to move the line to the Config file in system/

PHP Code:
'Config'      => APPPATH 'Config'

In the current state of affairs, moving the declaration of the Config namespace from the user config is the best solution.

(This post was last modified: 03-19-2023, 12:59 AM by iRedds.)

In general, a very strange situation. To be able to use autoloading of classes, in particular configs, you need to load half of these configs manually.

ps: Is there a thread discussing the architecture of the 5.x framework?
I believe that the framework's current architecture has many problems.
Therefore, I would like to express my opinion and know the opinion of people directly making decisions.
I don't get any feedback in this section of the forum other than @kenjis opinion

@iRedds Send a small PoC PR, or create an issue on GitHub.
Don't send big PR with 1000 line changes. Because nobody can review
and never be merged.

At least this forum is not the place.  Here is difficult to write/quote/read code,
so it is difficult to discuss.

Theme © iAndrew 2016 - Forum software by © MyBB