-
-
Notifications
You must be signed in to change notification settings - Fork 896
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
namespace php5 branch #243
Comments
👍 good idea. First we need to decide how our namespace should look like, I suggest: |
You should also probably decide if you want to lay things out PSR-0 or PSR-4 style. Right now, I'm packaging phpseclib into Fedora downstream. What should I consider the current 'canonical' upstream distribution and layout of phpseclib? At present I'm using the PEAR channel and packaging it PEAR-style. |
phpseclib should already be using PSR-0 style although I don't see anything wrong with the php5 branch using PSR-4 style if it wants to. And I'd say the master branch is the canonical version. If the php5 branch was the canonical version then it'd be better to have that be master and the current master be a php4 branch. Besides, all the documentation is for phpseclib without namespaces and updating that would not be fun. Really, I think a complete update of the look and feel and what not of the documentation might be in order but I'm thinking that's a good GSoC (Google Summer of Code) project (I want a free trip to Mountain View for the mentor summit lol) |
"phpseclib should already be using PSR-0 style" It isn't, no, it's using PEAR style. PSR-0 requires a minimum of two levels of namespacing. PSR-0 is designed to be inherently backwards compatible with PEAR-style, so any PSR-0 compliant loader will find and load things laid out PEAR-style, but that doesn't actually mean that they're PSR-0 compliant. They're PEAR compliant. |
oh, sorry, PSR-0 and PSR-4 both require a minimum of one level of namespacing (a vendor name). Neither requires two. |
@terrafrost Let's discuss how our namespace should be called. |
I'd like |
So be it. phpBB uses |
lower-casing stuff seems to be the current vogue in phpland, fwiw - composer/packagist recommend lowercase with - separators for module names. |
@terrafrost Do we want to keep the |
Actually, this might be a good idea. Will have to give this some more thought. |
idk.. either work lol. |
For the record: The decision whether to use "phpseclib" or "PhpSecLib" is kind of a marketing decision. The decision to use "phpseclib" has the benefit of being compatible to what is currently in use. Also, that is the name of the project and repository on github.
|
The autoloading shall be PSR-4 and it should just map the "phpseclib" namespace to the "phpseclib/" directory. No renaming or addition of directory levels required as far as I can see.
|
If it helps, based on my dive into the whole autoloading topic, I believe you're right there, but note that PSR-4 autoloading, unlike PSR-0, is not backwards-compatible with the PEAR 'underscores in class names translate to directory separators' convention: "Underscores have no special meaning in any portion of the fully qualified class name." So if you go with PSR-4, you'd have to fully namespace the code - you could keep the directory structure, but you'd need to convert all the class definitions to use namespacing. It sounds like that's what you are planning anyway, but I just thought I'd state it explicitly in case :) |
Yes, we do want everything under the phpseclib namespace in the php5 branch. |
Here are some example directory structures based on each style: PSR-0 or PSR-4 with no composer support (pretty much the same thing)
PSR-0 with composer support (Composer requires the vendor name and package name in the directory structure. Can be shortened by one directory by referring to subfolders (Crypt, File, Net, etc) as their own "package", but for full compliance this is correct.)
PSR-4 with composer support (also requires the vendor name and package name in the directory structure)
PSR-4 is obviously the newer standard which allows for a slightly more compact directory structure when using a package management system such as composer, which can be seem as a benefit to some. However as stated by @AdamWill PSR-4 will not allow pseudo namespaced class names i.e. Crypt_AES, NET_SSH2 etc. You could plan to migrate over to PSR-0 right now with the eventual goal of PSR-4 to happen after all the proper namespaces are created. The only other hangup is that there are a good number of calls to global constants (which are defined in each classes file) throughout the code which will NOT trigger an __autoload call, so this would need to be addressed at the same time. To go with PSR-4 right now, you would have to complete proper namespacing and migrate to class constants at the same time or find an alternate location to define the global variables until the class changes can be made. |
I need this lib fully support with psr standard, I will fork and make upgrade to be compatible with |
@Esysteme Hey. There is a pull request for PSR4. If you want to contribute please make sure you read related discussions. Otherwise you are probably going to waste your time and your changes won't be accepted upstream. |
lol I mostly converted all code :p |
you mean this fork ? |
@bantu what is the good one then? |
@Esysteme ?_? I guess you've been meaning to post #191 (comment) to this ticket instead. |
... which IMO makes PSR-4 a very poor standard. Not only does it break backwards compatibility, but it reduces one's ability to write efficient code. With PSR-0, I could do the following :
As a bonus, you get elegant, readable code that's mostly compatibly with old school PEAR-style naming conventions.
PSR-0 implements namespaces the way namespaces are meant to be used. It allows you to :
Not only is this a lot more elegant than the horrible PSR-4 standard, but it also makes it a lot easier to keep the main fork of PHPSecLib in sync with the PHP5 fork. Earlier today, I created a version of PHPSecLib that's fully compatible with PSR-0 and includes a PSR-0 autoloader. It required but minimal changes to the PHP5 fork of PHPSecLib. See #369 I won't bother to submit it, though, as long as @bantu sticks with his decision to keep the PSR-4 standard. |
See #374 for the code. |
For what it's worth, I think PSR-4 is the way to go. If anyone really needs to use this with PHP4, they'll have to use a previous release. |
👍 for psr-4. |
👍 |
PSR-4 👍 |
new to using phpseclib but for what it's worth +1 to PSR-4 |
Could this branch be tagged with a version so we can use it as a dependency in other composer packages? |
I thought it was already namespace'd but looking at it it does not appear to be..
The text was updated successfully, but these errors were encountered: