Skip to content
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

PSR-0 compatibility #4

Open
flack opened this issue Mar 23, 2013 · 6 comments
Open

PSR-0 compatibility #4

flack opened this issue Mar 23, 2013 · 6 comments

Comments

@flack
Copy link
Contributor

flack commented Mar 23, 2013

Right now, this package uses Captcha as its only namespace, which is a bit unfortunate, since it is a very generic namespace which increases the risk of collisions when used e.g. in an environment where multiple captcha implementations are integrated.

It would be better if the namespace would be something like AlekseyKorzun\ReCaptcha, i.e. have a vendor namespace as defined in PSR-0 (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md). If there is a vendor namespace, then the package namespace itself becomes less important, except of course when you decide to implement another captcha mechanism :-)

I know this is a bit inconvenient to implement, since it will break backwards compatibility, but maybe you could do it for a new (major) release.

@AlekseyKorzun
Copy link
Owner

That makes sense, but since this package has so many installs on Packagist which does not support renaming of projects without removing them first I'm hesitant to do so.

I might look into this more when I get a chance, maybe that's no longer the case.

@flack
Copy link
Contributor Author

flack commented Mar 28, 2013

AFAIK packagist still sucks in this regard. They don't allow you to remove packages either if they have more than 50 installs, so this wouldn't work anyways.

But my request is not such much about the name in composer.json, but rather the namespace used in the PHP classes themselves. Right now, you instantiate the widget like this:

$captcha = new Captcha\Captcha();

My proposal would be to use something like this instead:

$captcha = new AlekseyKorzun\ReCaptcha\Captcha();

The packagist setup doesn't have to change for this (but you might need to update the autoloader configuration in composer.json)

@AlekseyKorzun
Copy link
Owner

Why not just AlekseyKorzun\ReCaptcha ? Any opinion on that?

@flack
Copy link
Contributor Author

flack commented Mar 30, 2013

AlekseyKorzun\ReCaptcha works fine for me. I was suggesting the form with two namespaces because it is psr-0 compliant (they want everything in the format VendorName\PackageName\[optional other namespaces]\ClassName). psr-0 is not a real standard, so it's not terribly important to follow it, I just saw in your composer.json that you're using the psr-0 autoloader, but as long as it can find the classes, all is well

@AlekseyKorzun
Copy link
Owner

Gotcha, that makes sense I did not look at the document they drafted in a while now.

I might do this this weekend, still need to figure out what kind of impact this will do to users not using composer/packagist/etc.

@AlekseyKorzun
Copy link
Owner

@flack I think this is resolved. Just came across this... lol

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants