hoaproject / Core

The Hoa\Core library.

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Composer: PSR-4

Hywan opened this issue · comments

Hello :-),

Composer provides a PSR-4 autoloader since several months now. We didn't switch from PSR-0 to PSR-4 in composer.json files because we didn't know how many services are using the latest Composer version. I don't know more right now but I think we can say that we have waited enough time.

Why will it help?

Hoa's autoloader was already PSR-4. We have pointed out the lakes of PSR-0 many times since the origin of PSR-0 but… this is another topic. Anyway, Hoa's autoloader is PSR-4. Consequently, using the same autoloader specification will help to drop specific Composer's code (mainly when accessing to resources). It will help to drop the following code:

Modifing all composer.json

We will have to modify all the composer.json files at once and pushing everything at once. This will be like a small rush (potentially around 2-3am to avoid errors). I can create PR for every composer.json files, however, I will start by the one of this library in order to agree on the upcoming patches.

Thoughts?

/cc @hoaproject/hoackers

👍 we use PSR-4 since few months and it's pretty cool

Composer is not in stable mode, users/services have to upgrade theirs composer.

@stephpy What does it mean?

We didn't switch from PSR-0 to PSR-4 in composer.json files because we didn't know how many services are using the latest Composer version.

Related to that, if users have a version of composer which doesn't support psr-4, they should upgrade it ...

@stephpy: What is the source of your quote?

@Hywan you ? 3 days ago. In top of this page.

:trollface:

@stephpy :-p. Ok. Yes of course they have to upgrade their own version of Composer. Is it a problem?

Nope ;) Let's go for PSR-4.

All libraries have a PR updating the composer.json file. Hoa\Core has also a PR to update the behavior of hoa://Library/. Everything is ready. I will merge all that stuff tomorrow.

Everything works. Back to work.

Bonus with #44, now hoa://Library looks inside the parent of the vendor/ directory when installed through Composer. Thus:

$ git clone https://github.com/hoaproject/Ruler . # for instance
$ composer install
$ vendor/bin/hoa test:run -d Test

now works (it previously failed because hoa://Library/ were only resolved inside vendor/hoa/).

Thanks everyone for the help!