--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Please consider this essay a pre-proposal to gauge interest,
Please consider this essay a pre-proposal to gauge interest, especially among Composer users. This is *not* a call to end PSR-0; it is to suggest that it may make sense to provide an additional alternative.
Many find this structure to be deeper and more-repetitive than necessary.
The problem is that it would be possible to register Foo\Bar, and then Foo\Bar\Baz\Dib, and then Foo\Bar\Baz\Dib\Zim\Gir with separate locations. Thus, we would need to decide which one gets precedence.
In playing around with it, I opted for "deepest registered namespace takes precedence, then work your way back up."
You get bonus points for gratuitous Invader Zim references.
> I agree it makes sense for many people to do it. I just don't see any
> technical argument for this new spec to enforce it.
Fair; all I'm saying is that it appears to be a common practice among the voting members here, and since this groups was formed to find commonalities and codify them, it makes sense to me to recognize it.
The problem is that it would be possible to register Foo\Bar, and then Foo\Bar\Baz\Dib, and then Foo\Bar\Baz\Dib\Zim\Gir with separate locations. Thus, we would need to decide which one gets precedence.
My main concern with this proposal is with it having anything to do with how Composer (or any package manager, for that matter) manages dependencies in a vendor/ like directory. Most of the examples specifically show vendor/vendor_name/package_name structures to showcase the depth problem and how this proposals fixes them. In my opinion these are implementation details very specific to Composer and really should not have any impact on the consumer of the dependencies.
> I agree it makes sense for many people to do it. I just don't see any
> technical argument for this new spec to enforce it.
Fair; all I'm saying is that it appears to be a common practice among the voting members here, and since this groups was formed to find commonalities and codify them, it makes sense to me to recognize it.
I'd definitely like to see this not be enforced by the spec. People and projects should be smart enough to know when it makes sense to create a project namespace and when not to. Sure, I can choose to use PSR-0 instead of PSR-X... but that isn't nice. I'd basically be having to choose between a shorter directory structure or an artificially longer namespace. Instead, I could just be choosing PSR-X solely because I want a shorter directory structure and not have to make any concessions on how my project is namespaced.
vendor/
vendor_name/
package_name/
ClassName.php
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/JdR-g8ZxKa8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
Ah so. Even then, it doesn't appear to be the case.
On Apr 2, 2013, at 6:45 PM, Amy Stephen wrote:
> Paul - when I said "I disagree" is was related to your initial comment that your proposal is a deviation from PSR-0. I do not believe that is the case. I believe your proposal is still in support of PSR-0.
PSR-0 requires a direct class-to-file mapping.
For example, if a class is named "Foo\Bar\Baz\Dib", the terminating path for that class must be "Foo/Bar/Baz.php".
Registering the namespace "Foo\Bar" to a path of "/path/to/package" means the class file must be located at "/path/to/package/Foo/Bar/Baz/Dib.php".
The package-oriented proposal, on the other hand, maps a registered namespace prefix to an arbitrary directory; the namespace prefix portion of the class name is stripped before converting the remainder to terminating path.
Thus, registering the same namespace "Foo\Bar" to the same path of "/path/to/package" means the same class file must be located at "/path/to/package/Baz/Dib.php".
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/JdR-g8ZxKa8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
The "src" and "tests" directories have to include vendor and package directory names. This is an artifact of PSR-0 compliance.
The "src" and "tests" directories have to include vendor and package directory names. This is an artifact of PSR-0 compliance.
I know most folks are building packages this way - but this is a convention that people are following that is in no way required for PSR-0 compliance.
I believe the src folder convention is a big part of the problem. It creates three folder layers src/Vendor/Package -- unnecessarily.
If the package root is where the application files and folders are located, those three layers are gone.
The only problem that then remains is that Composer creates lowercase Vendor/Package folders. If Composer instead used the same case that the Vendor/Package requires - all extra layers would be gone.
--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/php-fig/-/HKRbbAWbPaYJ.
The first version proposal did that; it specified two namespace names, Vendor and Package. Then Larry Garfield and others pointed out that an arbitrary number of namespaces makes it independent of any particular package manager.
The fact that they *must* include the vendor and package names as empty directories inside "src" and "tests" is required for PSR-0 compliance.
On Apr 2, 2013, at 9:37 PM, Amy Stephen wrote:
>> The "src" and "tests" directories have to include vendor and package directory names. This is an artifact of PSR-0 compliance.
>
> I know most folks are building packages this way - but this is a convention that people are following that is in no way required for PSR-0 compliance.
vendor/
foo/
bar/
assets/
image.jpg
style.css
data/
data.csv
data.ini
src/
Foo/
Bar/
Baz.php # Foo\Bar\Baz.php
tests/
Foo/
Bar/
BazTest.php # Foo\Bar\BazTest.php
... you can have this structure under the proposed alternative:
vendor/
foo/
bar/
assets/
image.jpg
style.css
data/
data.csv
data.ini
src/
Baz.php # Foo\Bar\Baz.php
tests/
BazTest.php # Foo\Bar\BazTest.php
Allowing non-top-of-the-tree roots doesn't do anything for the composer-generated vendor/foo/bar/src part, but it does shorten the paths below that. With the classes you name, you'd have:
vendor/
/molajo
/package
/src
/Foo
/Bar.php
/aura
/package
/src
/Foo
/Bar.php
So there's no conflict. That said, I have a feeling that this won't
be of use to free-standing libraries as much as to plugins for
specific projects. Eg, Drupal modules, Joomla plugins, etc. As
someone who works mostly in that space, though, I like the idea of
making our paths shorter. :-)
-- pmj
Neither toward nor away from it. The name of the directory where the packages are stored is entirely inconsequential to the proposal.
On Apr 2, 2013, at 11:09 PM, Amy Stephen wrote:
> So, you are moving away from vendor? (And I'm still confused about Composer as a side issue.)
Yes, I like PSR-0. It's not being thrown out. But I don't see how we can remove the directories that map to the registered namespace *and* stay within PSR-0, which requires a direct class-to-file mapping.
> Paul - I think you are trying to solve the same problem but throwing the baby out with the bath water. PSR-0 is fine. It's a combination of factors that create those extra folders. We could fix the problem and keep everyone on the same standard.
namespace Molajo\FieldHandler\Type;
My current state:
Besides Amy, who here is finding this "complex" and "hard to explain" ?
Does that make it clearer what the benefit is?
Extension\Theme\Foundation\Plugin\Foundation;
--Larry Garfield
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/JdR-g8ZxKa8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to php-fig+unsubscribe@googlegroups.com.
and I believe they might be causing some confusion. In that previous discussion you linked to where you brought this up, you were referencing these examples like they are being used with Composer, but they aren't.
The src/ folderI've noticed you saying a few times we should kill the src/ folder convention, but thats not really anything to do with the autoloaders we're discussing.
That's just a convention that people happen to use
It's cool - I get the problem - but I preferred to stay PSR-0 compliant. I'd personally rather everyone do so - but - I'm not a member anyway.
* // Example which loads classes for the Doctrine Common package in the* // Doctrine\Common namespace.* $classLoader = new SplClassLoader('Doctrine\Common', '/path/to/doctrine');* $classLoader->register();
mkdir vendorcd vendorgit clone g...@github.com:doctrine/common.git doctrine-commongit clone g...@github.com:symfony/HttpFoundation.git symfony-http-foundation
$classLoader->add('Doctrine\\Common', 'vendor/doctrine-common/lib');$classLoader->add('Symfony\\Component\\HttpFoundation', 'vendor/symfony-foundation');
It's complex, hard to explain, can a few of us who are interested in this schedule a voice meeting and start with trying to get a good understanding on where these extra layers are coming from?
* `\Zend\Acl` => `/path/to/project/lib/vendor/zend/framework/src/Zend/Acl.php`* `\Zend\Mail\Message` => `/path/to/project/lib/vendor/zend/framework/src/Zend/Mail/Message.php`Notice how zend/framework != Zend/Acl or Zend\Mail? That means this new autoloader would never work with them. But, that is ok. That's why having both seems to me like a great idea. To the outside user its identical, to the package developer they can chose to skip this folder structure if they follow a few careful rules about how they name their package. win win, right?
On Tuesday, April 2, 2013 11:43:57 PM UTC-5, Amy Stephen wrote:It's cool - I get the problem - but I preferred to stay PSR-0 compliant. I'd personally rather everyone do so - but - I'm not a member anyway.Hi Amy!I wasn't able to jump in last night so I may have missed the boat, but some of what you wrote made makes it clear that you feel pretty strongly that a lot of people, Composer included, are not PSR-0 compliant. So I tried to read PSR-0 with a fresh set of eyes.
Composer is *perfectly* PSR-0 compliant. It just adds a couple of extra folders I could do without.
I don't know where "a lot of people" comes from, everything I have reviewed is PSR-0 compliant.
No, I don't make any assumptions that the name space must be in Vendor to be PSR-0 compliant, either.
Both Composer and Packagist say that the first two values are *supposed to be* PSR-0 compliant, and as such, should represent your Vendor-name/Package-name portion of the namespace.
The most important part is that the first bit of the package name must be the vendor name, suffixed by a forward slash (/). This follows the PSR-0 standard for namespaces naming.
The package name consists of a vendor name and the project's name. Often these will be identical - the vendor name just exists to prevent naming clashes. It allows two different people to create a library named json, which would then just be named igorw/json and seldaek/json.
Here we are requiring monolog/monolog, so the vendor name is the same as the project's name. For projects with a unique name this is recommended. It also allows adding more related projects under the same namespace later on. If you are maintaining a library, this would make it really easy to split it up into smaller decoupled parts.
Again - there are lots of factors at play. Some parts are the standard, other the tools we share, others are convention. I tried to sort thru where choices impact the length of the install path for those who care about short paths and still want to stay compliant.
Beau - does that help clear up my point?
--
You received this message because you are subscribed to a topic in the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php-fig/JdR-g8ZxKa8/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to php-fig+u...@googlegroups.com.
To post to this group, send email to php...@googlegroups.com.
If Composer did not use the same value for name twice in the path;
If the Composer name values were allowed in mixed case and then could be used as part of the namespace;
Do not add folders to the "top" of your package repository that are not a part of your namespace.
Let's get back on topic for Paul's and Larry's approach. Larry gave an example of Drupal code that will never be a shared package and how to handle namespacing there.
It's my opinion that PSR-0's scope is *shared packages* (typically) installed into the Vendor folder.
Going to have to have Beau change that, not sure what it should be - thanks Jordi.