-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move global Krautoload class for PSR-0 compatibility #10
Comments
Hi, Truth is... I don't like that part of PSR-0 very much. There is a reason why PSR-4 is going to drop this requirement. The additional vendor namespace will not add any practical benefit. I don't know of anything out there that would break if some library has a one-level namespace. On the other hand, it does have some clear disadvantages:
Looking around, I find one library which does the same: Assetic. (and of course every PEAR library, which PSR-0 wants to be backwards-compatible with) For the \Krautoload::start() in top-level namespace, I know at least one other piece of code which does that - Drupal 8. Now this might not be the perfect example. But it clearly is pretty pretty useful. |
So, I might be convinced, but I need some real-world practical arguments. Such as, real-world compatibility issues. |
Well, I'll admit I'm not a fan of the FIG either. Think of it as a play-nice-with-others thing. PHP developers are finally creating themselves an ecosystem which revolves around easily deployable and adaptable packages and everything depends on creating a common ground of basic plumbings to build on. The ideas there aren't new, they come from past experiences in projects created and/or maintained by FIG participants. The "vendor" (I still don't like that name no matter how many times I read it) prefix is probably an idea inspired by Java where by convention packages use reverse domain names in order to create unique namespaces for themselves (e.g. com.acme.widgets). PSR-X replaces the vendor prefix with a base directory to avoid having a set of extra subdirectories for add-on/plugin packages. So for instance, ACME has a namespace for widget adapters ACME\Widget\Adapter and you're writing an optional package for square widgets. You'd have to create all these directories: src/ACME/Widget/Adapter and place Square.php in there. PSR-X addresses this by allowing you to skip the extra directories and define 'src' as the root of your ACME\Widget\Adapter namespace. Now there are several things going on here:
This means that you still have to namespace everything and _ is no longer mapped to /. For Krautoload, this would require some additional refactoring. Regardless of what autoloading standard you use, I'd argue that calling the global EDIT: I've updated the title. The way I see it, the only thing that's missing for PSR-0 compatibility is the requirement that every class must be namespaced. So, that's just one class here. |
Well.. I think we both know quite well what PSR-0 and PSR-X are about, so this is mostly an opinion / taste and attitude towards PSRs discussion .. I personally do care about the standards "on paper", but I also care about the developers who may use this software (who want it to play nice with other PSR-compliant libraries). And if in conflict, I'd rather pick the latter..
Yes, I absolutely support this notion. The first requirement of PSR-0 about the vendor namespace is "required" on paper, but noone actually builds any technical assumptions on it. The theoretical case would be if a project wants to include a PaulVG\Krautoload and a Donquixote\Krautoload at the same time. I personally don't see that as a realistic scenario. You pick either one or the other, or you create your own. Otherwise, Symfony would have to be FabPot\Symfony.. For my taste, the vendor is "the Krautoload community" (which atm is mostly a single person, or the 3 people who are participating in the issue queue). And the package is "the Krautoload class loader". Having Maybe it would make sense to say |
Yes.. we are not at PSR-4 yet for Krautoload. On the other hand, no-underscore is not a universal i-win button for nice class names: Going all PSR-4 is not a goal atm. Someone may want to use Krautoload as a library only for class discovery, so it has to work with the class loading shipped with composer. On the other hand, most other modern PSR-0 projects work underscore-less, so it should be considered to get rid of the underscores, and use namespaces for the directory organization. I am a little afraid this will not make the library nicer to look at, rather the contrary. |
See, you are doing it yourself :) |
We could name it like Krautoload\Main::start() or Krautoload\StaticBoot::start() or whatever. The idea was also that the class Krautoload itself may not directly participate in PSR-0 or PSR-4 class loading. So, if you read PSR-0 / PSR-4 as "every class that wants to be class-loaded with PSR-0 / PSR-4 must/should etc", then it would be just fine. The other thing is naming collisions.. and I don't think that class Krautoload will collide with anything.
Hmm.. what are you refering to? |
This being said - if you have a convincing suggestion for Krautoload\Something::start(), I might consider it :) |
As of right now, there's no "Vendor Name"[sic] namespace which breaks this mandatory requirement:
Preferably, Krautoload shouldn't declare a class in the global namespace. Such is just bad practise.
My suggestion: Move everything to Donquixote\Krautoload.
The text was updated successfully, but these errors were encountered: