[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [jfw] Failing build of some packages



With PSR-0, the file path is an exact reflection of the class namespace, with the exception of underscores also being replaced with directory separators, in the designated directory. There is no prefix replacement. This is counter to how the JLoader::registerPrefix() in the CMS works, where the prefix is stripped off, then loaded from the directory by splitting on CamelCase. So JFooBar (registered with a root of libraries/joomla/) can be found at libraries/joomla/foo/bar.php

Then comes PSR-4, which is actually closer to how the Joomla prefix-based loader works. The registered prefix gets stripped from the class name, and the remaining part is then transformed into a class path.

The files in the form package need to be moved to a src/ directory, then have the class names (and file names) changed to (for example) Jooml\Form\Field\ListField, etc. This will allow us to use a PSR-4 autoloader and then everything should work fine. This change would require a major version increment. Also, all v2 packages of the framework are licensed as LGPL 2.1+ (as a result of OSM's recent decision) so this is a good time to make the other breaking changes (such as the class name changes) and then release v2.


On Sun, May 4, 2014 at 4:24 AM, Achal Aggarwal <theachalaggarwal AT gmail.com> wrote:
Haha, yeah I should have. Please explain psr-0 autoloader prefix replacement policy.
I understand that we can set a prefix and its path in composer and then it uses this prefix in someway.

In psr-4, prefix is matched with namespaced class and it is replaced with path. Isn't that the case with psr-0 also. I am talking about only custom namespaces, checkout last section ("Bonus Round") of https://jtreminio.com/2012/10/composer-namespaces-in-5-minutes/

In psr-0 autoloading is this correct?
"autoload": {
        "psr-0": {
            "Foo\\Bar\\": "src"
        }
    },

and Foo\Bar\Abc_Qwe class is present in src/Foo/Bar/Abc/Qwe.php, I guess this one is correct as it is working flawlessly.

and in psr-4 Foo\Bar\Abc_Qwe class should be present in src/Abc_Qwe.php


--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.

--
Framework source code: https://github.com/joomla/joomla-framework
Visit http://developer.joomla.org for more information about developing with Joomla!
---
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com.
Visit this group at http://groups.google.com/group/joomla-dev-framework.