Map-based autoloader across php and phar resources

โŒˆโŒ‹ โŽ‡ branch:  Canonic Autoloader


Update of "FeatureComparison"

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview

Artifact ID: ad6ecaf1bb210163846d1be6f9d120873f805bd8
Page Name:FeatureComparison
Date: 2014-09-04 02:08:08
Original User: mario
Mimetype:text/x-markdown
Parent: 9eb2a4de0db7232aefc06b97ac615298b8c9214b (diff)
Next 7205d9f431d014f44c79b7f9c313daa3d59c465c
Content

Let me just preface this with: inconclusive conventions are better than no standards at all. And there's really nothing newsworthy here.
Due to the ellipses in the PSR-x documents it's however helpful to detail some technical deviations and oversights.

Feature PHP PSR-0 PSR-4 shared
Class autoloading โœ” โœ” โœ” โœ”
Zero configuration โœ” โ€Šโœ” โœ˜โ€Š โœ˜
Multiple class declarations per script โœ” โœ˜โ€Šยน โœ˜โ€Šยน โœ”
Namespace support โœ” โœ” โœ” โœ”
Multiple namespaces per file โœ” โœ˜โ€Š โœ˜โ€Š โœ”
Syntax verification โœ” โœ˜โ€Š โœ˜โ€Š โœ˜
Specific underscore treatment โœ˜ โ€Šโœ” โœ˜โ€Š โœ˜
Case-insensitive class identifiers ยฒ โœ” โœ˜โ€Š โœ˜โ€Šยฒ โœ”
Function names โœ” โฟ/โ‚ โฟ/โ‚ โœ”
Case-variant constants โœ” โฟ/โ‚ โ€Šโฟ/โ‚ โœ˜
Phar package support โœ” โœ˜โ€Šยณ โœ˜โ€Šโ€Šยณ โœ”
Versioned bundles โด โœ” โœ˜โ€Š โœ˜โ€Š โœ˜

  1. Impractical, but symlinking dependency-conjoined class modules might be a feasible workaround.
  2. Not just accidentally on some plattforms or filesystems.
  3. While prohibited, some PSR-0 and a few PSR-4 autoloaders work with handicrafted phar:// paths in their namespace registry.
  4. Dependency resolution is mostly off-scope for runtime autoloading, and obviously best left with composer.

Origin of PSR-0/4

PSR-4 inherits the PSR-0 design as intended for and from PHP framework maintainers. Retaining the traditional class directory structures was the protogenic goal then. PSR-4 constitutively just removed the PEAR-style name splitting.

Which is where the absent identifier-to-file case normalization issues from. The focus on legacy directory schemes is also how Phar support got completely disregarded (as if PHP 5.3 was only about namespacing all the things).

Composer relationship

Composer is married to PSR-0/4. Technically it's not a dependency, as highlighted by Composers very own classmap generator. (Which however stockholm-syndromes the shallow singly-namespaced-class-per-file semantics, invalid identifier mapping, and overlooked phar support).

As package installation mediator it can however abstract away some source management deficiencies. Applying some late common sense and strtolower becomes a facile possibility.