Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load modules #306

Closed
thekid opened this issue Dec 30, 2015 · 3 comments
Closed

Load modules #306

thekid opened this issue Dec 30, 2015 · 3 comments

Comments

@thekid
Copy link
Member

thekid commented Dec 30, 2015

Scope of Change

This RFC suggests adding a command line switch to load modules: xp -m [path-to-module] being the (rough) equivalent of xp -cp [path-to-module]/src/main/php.

Rationale

A central idea of XP 7 is framework modularity. This means many packages previously part of the framework now need to be referenced by either adding them to the class path or by spelling out all the class path entries (plus those of transitive dependencies) on the command line. Running a script to query the database will require either creating a composer.json and running composer or using the longish xp -cp ~/xp/rdbms/src/main/php -cp ~/xp/networking/src/main/php -cp ~/xp/logging/src/main/php -cp ~/xp/math/src/main/php Script.

Functionality

Syntax: xp [-m module [-m module [-m ...]]] <options> <Class>

The module argument references a module by its top-level directory. The determined directory is then scanned for path files which finally make up the class path.

Security considerations

n/a

Speed impact

Supplying -m module is slightly slower than -cp module/src/main/php since the first parses path files to determine the directories. As -cp is retained, no harm is done.

Dependencies

Since all module paths are simply added to the use path, this change is compatible with XP5, XP6 and the upcoming XP7!

Related documents

@thekid
Copy link
Member Author

thekid commented Dec 31, 2015

The following was removed because I wasn't too happy with the complexity it added:


The module argument references a module by its qualified name [vendor]/[package]. If module is an existent directory, all path files inside it are scanned for class path entries. Otherwise, the module path defined via xp.ini is scanned. It defaults to $COMPOSER_HOME/vendor/{vendor}/{name}.

Composer integration

The module path defaults to $COMPOSER_HOME/vendor/{vendor}/{name}, which is used by composer global require ...:

  • Un*x: /home/$USER/.composer/vendor/{vendor}/{name}
  • Mac: /Users/$USER/.composer/vendor/{vendor}/{name}
  • Windows: C:\Users\$USER\AppData\Roaming\Composer\vendor\{vendor}\{name}
  • Cygwin: First checks for Un*x path, then Windows

Configuring the module path

The path can also be set inside xp.ini as follows:

[runtime]
date.timezone=Europe/Berlin
modules=~/devel/{vendor}/{name}
extension=php_com_dotnet.dll

The module xp-framework/logging will assumed to be in ~/devel/xp-framework/logging, which could contain a git checkout.


We're able to create the new relatively simple approach first without breaking anything in a way where this could not be added later.

@thekid
Copy link
Member Author

thekid commented Dec 31, 2015

💚 There is no impact on the framework from this RFC and no change necessary, removed "framework" label and added note that this is compatible with XP5, XP6 and the upcoming XP7.

thekid added a commit to xp-framework/xp-runners that referenced this issue Dec 31, 2015
@thekid
Copy link
Member Author

thekid commented Dec 31, 2015

:shipit: Released in XP Runners 6.0.0

@thekid thekid closed this as completed Dec 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant