xp-framework / core
The XP framework is an all-purpose, object oriented PHP framework.
Installs: 194 444
Dependents: 97
Suggesters: 0
Security: 0
Stars: 19
Watchers: 18
Forks: 6
Open Issues: 1
Requires
- php: >=7.4.0
Suggests
- php: >=8.2.0
- dev-main
- v12.1.0
- v12.0.1
- v12.0.0
- v11.9.0
- v11.8.3
- v11.8.2
- v11.8.1
- v11.8.0
- v11.7.0
- v11.6.0
- v11.5.0
- v11.4.7
- v11.4.6
- v11.4.5
- v11.4.4
- v11.4.3
- v11.4.2
- v11.4.1
- v11.4.0
- v11.3.1
- v11.3.0
- v11.2.0
- v11.1.2
- v11.1.1
- v11.1.0
- v11.0.0
- v10.16.0
- v10.15.1
- v10.15.0
- v10.14.0
- v10.13.1
- v10.13.0
- v10.12.4
- v10.12.3
- v10.12.2
- v10.12.1
- v10.12.0
- v10.11.1
- v10.11.0
- v10.10.0
- v10.9.1
- v10.9.0
- v10.8.1
- v10.8.0
- v10.7.0
- v10.6.1
- v10.6.0
- v10.5.3
- v10.5.2
- v10.5.1
- v10.5.0
- v10.4.0
- v10.3.3
- v10.3.2
- v10.3.1
- v10.3.0
- v10.2.0
- v10.1.0
- v10.0.5
- v10.0.4
- v10.0.3
- v10.0.2
- v10.0.1
- v10.0.0
- v9.10.0
- v9.9.1
- v9.9.0
- v9.8.3
- v9.8.2
- v9.8.1
- v9.8.0
- v9.7.0
- v9.6.0
- v9.5.4
- v9.5.3
- v9.5.2
- v9.5.1
- v9.5.0
- v9.4.1
- v9.4.0
- v9.3.2
- v9.3.1
- v9.3.0
- v9.2.0
- v9.1.0
- v9.0.0
- v8.2.0
- v8.1.2
- v8.1.1
- v8.1.0
- v8.0.0
- v7.8.0
- v7.7.0
- v7.6.1
- v7.6.0
- v7.5.0
- v7.4.0
- v7.3.1
- v7.3.0
- v7.2.1
- v7.2.0
- v7.1.2
- v7.1.1
- v7.1.0
- v7.0.1
- v7.0.0
- v6.13.2
- v6.13.1
- v6.13.0
- v6.12.0
- v6.11.4
- v6.11.3
- v6.11.2
- v6.11.1
- v6.11.0
- v6.10.3
- v6.10.2
- v6.10.1
- v6.10.0
- v6.9.2
- v6.9.1
- v6.9.0
- v6.8.0
- v6.7.0
- v6.6.0
- v6.5.6
- v6.5.5
- v6.5.4
- v6.5.3
- v6.5.2
- v6.5.1
- v6.5.0
- v6.4.2
- v6.4.1
- v6.4.0
- v6.3.7
- v6.3.6
- v6.3.5
- 6.3.4.x-dev
- v6.3.4
- v6.3.3
- v6.3.2
- v6.3.1
- v6.3.0
- v6.2.5
- v6.2.4
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2.0
- v6.1.1
- v6.1.0
- v6.0.1
- v6.0.0
- v6.0.0beta3
- v6.0.0beta2
- v6.0.0beta1
- v6.0.0alpha7
- v6.0.0alpha6
- v6.0.0alpha5
- v6.0.0alpha4
- v6.0.0alpha3
- dev-eleven
- dev-ten
- dev-nine
- dev-six
- dev-eight
- dev-seven
- dev-v6.3.4-backports
This package is auto-updated.
Last update: 2024-11-24 10:02:25 UTC
README
This is the XP Framework's development checkout.
Installation
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.
Runners
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://baltocdn.com/xp-framework/xp-runners/distribution/downloads/i/installer/setup-8.8.0.sh | sh
Using it
To use the the XP Framework development checkout, put the following in your ~/bin/xp.ini
file:
use=/path/to/xp/core
Finally, start xp -v
to see it working:
$ xp -v XP 12.1.1-dev { PHP/8.3.10 & Zend/4.3.10 } @ Windows NT SURFACE 10.0 build 22631 (Windows 11) AMD64 Copyright (c) 2001-2024 the XP group FileSystemCL<./src/main/php> FileSystemCL<./src/test/php> FileSystemCL<./src/main/resources> FileSystemCL<./src/test/resources> FileSystemCL<.>
Basic usage
The XP Framework runs scripts or classes.
Hello World
Save the following sourcecode to a file called ageindays.script.php
:
<?php namespace examples; use util\{Date, Dates}; use util\cmd\Console; $span= Dates::diff(new Date($argv[1]), Date::now()); Console::writeLine('Hey, you are ', $span->getDays(), ' days old');
Now run it:
$ xp ageindays.script.php 1977-12-14 Hey, you are 16015 days old
Alternatively, you can put this code inside a class and give it a static main method. This way, you can use features like inheritance, trait inclusion etcetera. This time, save the code to a file called AgeInDays.class.php
.
<?php use util\{Date, Dates}; use util\cmd\Console; class AgeInDays { public static function main(array $args): int { $span= Dates::diff(new Date($args[0]), Date::now()); Console::writeLine('Hey, you are ', $span->getDays(), ' days old'); return 0; } }
Note the arguments have shifted by one: If you want the class' name, simply use self::class
!
$ xp AgeInDays 1977-12-14 Hey, you are 16015 days old
Contributing
To contribute, use the GitHub way - fork, hack, and submit a pull request!
Enjoy!