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: 9eb2a4de0db7232aefc06b97ac615298b8c9214b
Page Name:FeatureComparison
Date: 2014-09-02 20:33:08
Original User: mario
Mimetype:text/x-markdown
Parent: 979cde52ced37195ce4daba5685d8edf82a7af1f
Content

Let me just preface this with: inconclusive conventions are better than no standards at all. And there's probably 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, most PSR-0 autoloaders work with handicrafted phar:// paths in their namespace registry.
  4. Not a discreet PHP or Phar feature, and resolving dependencies is certainly still best left with composer, not done at runtime.

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 plattform ambiguity due to absent identifier-to-file case normalization issues from. Holding on to the handed down file structuring schemes is also why namespaces were interpreted as PHP 5.3s only significant addition, but Phar support disregarded.

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 infers the shallow semantics of singly-namespaced-class-per-file, invalid identifier mapping, zilch phar support).

Divorcing your way out of an abusive marriage is no small feat. Yet composer may keep the kids. When extracting packages, it's neither out of the picture to apply some common sense and strtolower, or repackage coherent bundles into phars. Thus development sources still may follow any of the framework guidelines, yet be used unambiguously cross-plattform.