hoaproject / Core

The Hoa\Core library.

Home Page:https://hoa-project.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Be able to toggle activation of Autoloading system.

stephpy opened this issue · comments

hi,

Point 1: At this moment, all libraries has dependency on hoaproject/core, itself has a autoloading system and users may not want to have a Xth autoloading system activated.

Point 2: If you're agree with that, should it be activated by default ? Should this autoloading system be enabled on a full stack version of hoa ? (sohoa)

Thought ?

Hello :-),

Hoa's autoloader must be activated if someone uses the from/import mechanism (to profit of patterns, foreachImport and so on). When using with Composer, Symfony, Sohoa etc., new autoloaders are appended (not prepended) by default to the stack of autoloader. If an autoloader successes to load a class, Hoa's autoloader will never run. In this case, yes, it could be absent, except in some cases, e.g.: when using a short-classname instead of a FQCN.

So we can't disable Hoa's autoloader without creating errors. Is it annoying to have Hoa's autoloader enable? This is a better question I think.

Thoughts?

Indeed if we let user choose to toggle hoa's autoloader, he'll have to know than from/import and short-classname will not be supported.

I'm not saying than hoa's autoloader is annoying, just than being able to toggle it would be useful.

In Symfony it's OK, but hoa's autoloader could have some “conflicts“ with an other framework/tool and in this case, it would be really useful.

Why kind of conflicts? Nobody reports any issue for now. If a class is not found by Hoa's autoloader, then, the next autoloader will run. This is how autoloaders work :-/. I don't see your point.

I've no example and it's may be impossible to have conflicts, i don't know ...

But when you use composer autoloader, you do it manually require "vendor/autoload.php";. Nobody forces you to use this autoloader, but here, if you install hoa via composer, you are forced to use hoa autoloader.
At this moment, if i'm sure than X or Y autoloader is not useful for me, i prefer to not activate it ... to avoir errors, calls not usefuls, etc ...

It's a matter of choice IMO, let user choose is the best philosophy to be appreciated.

If you install Hoa via Composer, you are not forced to use Hoa's autoloader. You actually use the Composer's one, with some fallbacks to Hoa's one when necessary. And Hoa's libraries sometimes need Hoa's autoloader for specific usage (like foreachImport, some patterns in import etc.).

I understand you prefer to disable apparently unnecessary code, but it's necessary and it's just… ≃ 60 LOC. And this is how autoloaders work. I don't know understand where is the problem actually :-/.

Since Hoa's autoloader is needed for Hoa's libraries, I propose to close this issue :-). Are you agree?

Yep, indeed ;)