This is the XP Framework's development checkout.
If you just want to use the XP Framework, grab a release using composer require xp-framework/core. If you wish to use this development checkout, clone this repository instead.
The entry point for software written in the XP Framework is not the PHP interpreter's CLI / web server API but either a command line runner or a specialized web entry point. These runners can be installed by using the following one-liner:
$ cd ~/bin
$ curl -sSL https://bintray.com/artifact/download/xp-runners/generic/setup-7.4.0.sh | shTo use the the XP Framework development checkout, put the following in your ~/bin/xp.ini file:
use=/path/to/xp/coreFinally, start xp -v to see it working:
$ xp -v
XP 7.2.1-dev { PHP 7.0.3 & ZE 3.0.0 } @ Windows NT SLATE 10.0 build 10586 (Windows 10) i586
Copyright (c) 2001-2016 the XP group
FileSystemCL<./src/main/php>
FileSystemCL<./src/test/php>
FileSystemCL<./src/main/resources>
FileSystemCL<./src/test/resources>
FileSystemCL<.>The XP Framework runs classes with a public static main() method. To run a class, supply the fully qualified classname as command line argument: $ xp {class.Name}.
Any argument after the classname will be passed to the class' main method.
Save the following sourcecode to a file called AgeInDays.class.php:
<?php
use util\{Date, DateUtil};
use util\cmd\Console;
class AgeInDays {
public static function main(array $args) {
$span= DateUtil::timespanBetween(new Date($args[0]), Date::now());
Console::writeLine('Hey, you are ', $span->getDays(), ' days old');
}
}Now run it:
$ xp AgeInDays 1977-12-14
Hey, you are 13724 days oldAlternatively, you can run this directly in the shell:
$ xp -w '
use util\{Date, DateUtil};
$span= DateUtil::timespanBetween(new Date($argv[1]), Date::now());
return "Hey, you are ".$span->getDays()." days old"
' 1977-12-14
Hey, you are 13724 days oldEnjoy!
To contribute, use the GitHub way - fork, hack, and submit a pull request! ![]()





