On 14/08/2019 11:17, Michał Brzuchalski wrote:
Following that would introduce unneeded additional directory hierarchy
level in a usual library
which uses PSR-4 which is the most used one, right?
/composer.json
/src/Foo.php
/src/Foo/ <- all package classes should go here?
That would be one place to put it, yes. But it would be entirely up to
how people wanted to define their autoloader, that's the beauty of it.
There's no reason something couldn't generate an autoloader that
essentially said this:
function autoload($name) {
if ( $name == self::PACKAGE_NAME ) {
require self::SRC_DIR . '/__packagedef.php';
} elseif ( str_begins_with($name, self::BASE_NAMESPACE) ) {
require self::SRC_DIR . str_replace('\\', '/', $name) . '.php';
}
}
Please don't pick holes in that implementation; my point is, if this was
how packages were implemented, people would decide how they wanted to
use it, and PSR-4 would probably be superseded by something which
accounted for packages existing.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php