xp-framework/rfc

Module loading

Opened this issue · 2 comments

Scope of Change

This RFC suggests adding the ability to load modules via class.pth.

Rationale

There is no counterpart for the command line option -m.

Functionality

# Local path and file references
src/main/php/
?vendor/autoload.php

# New: This is a module reference. Its path will be scanned for *.pth files
@../xp/inject/

Security considerations

n/a

Speed impact

Overhead (if not used) is one additional comparison: '@' === $path{0}; not measurable.

Dependencies

Implemented inside XP runners completely, compatible with all XP versions.

Related documents

RFC #318

Running with older XP runners, users will see errors like this:

$ xp -v
Uncaught exception: Exception ([bootstrap] Classpath element [./@../xp/inject/] not found)

💭 Second thought

Not entirely sure about this RFC's usefulness.

➖ Useful when handwiring dependencies; users will typically use Composer, though.
➕ On the other hand, it does create consistency with the command line.
➕ And its implementation only means a couple of lines of code.