php-openid
php-openid copied to clipboard
Using PSR-0 compatible autoloader can't load all classes (& composer.json)
php-openid library is currently a little bit unorganized in terms of the classes and their position in the file tree.
There are certain classes hidden in the "parent" file, like \Auth_OpenID_AX_FetchResponse();
that requires Auth/OpenID/AX.php file. Complying with PSR-0 autoloading standard, it would be preferred that the class should reside in its own file (Auth/OpenID/AX/FetchResponse.php)
I have used to load php-openid with (similar to) following lines in the composer.json file:
"package": {
"name": "openid/php-openid",
"version": "dev-master",
"source": {
"url": "https://github.com/openid/php-openid",
"type": "git",
"reference": "39206ec13b29e43f8cf604158ac7d1530ec29ee1"
},
"autoload": {
"psr-0": {
"Auth_": "./"
}
},
"include-path": ["./"]
}
Most of the classes work fine and no additional require()
or include()
calls are needed around application. However, Auth_OpenID_FetchResponse() is one that does not work.
Is there some reason that the code & classes are not organized in PSR-0 compliant way? Backwards compatibility? I am happy to contribute in the process of re-organization, if no issues come to your mind right away.
This is something that has existed in the library since I can remember. Unfortunately, I don't think any of the decision makers responsible for this are even around to answer why it's done in this fashion. Ideally, yes, this library should be PSR-0 compliant. However, I don't think that decision should be made lightly without first looking in to and discussing the potential ramifications of a move to do this. In the end a decision would have to be made to either in sure everything was backwards compatible or break compat, bump up the X version number, torch the past and look forward.
Thanks @marcoceppi for your comments, I agree.
In terms of composer.json compatibility, I think the correct way would be to use classmap autoloading instead of psr-0 autoloading. That would do the trick at least for the beginning.
{
"type": "package",
"package": {
"name": "openid/php-openid",
"version": "dev-master",
"source": {
"url": "https://github.com/openid/php-openid",
"type": "git",
"reference": "487d18593624a2e612177b356486b4699469f7ac"
},
"autoload": {
"classmap": ["Auth/"]
},
"include-path": ["./"]
}
}
Still, for the future, the library should drive towards PSR-0 compatibility. I would suggest also considering code reorganization to namespaced world, as PHP 5.2 (the last release without namespace support) has came to it's EOL over two years ago. It might also be a good point for PSR-0 compatibility as changes in the previous code utilizing the library is definitely required to change.
I agree and have had an itching to clean up this library and gear it towards future versions of PHP and not past versions. I'll start a topic on the discussion board for further feedback and planning. Leaving this open as a reminder
This repo is being archived. Closing issue.