A port of the js framework virgilio to php
- argument spreading for functions defined on a namespace
We hate massive include lists
The main goal of this framework is foremostly to prevent having to import a lot of different files to access their functionality. Virp tries to eliviate this by having you define all functions on virpSpaces which Virp keeps track of internally. This makes it possible to only have to import one file and have access to all namespaces and functions in other files.
file A.php
include "../virp/index.php";
$app = virp::init();
$myNamespace = $app::virpspace("myNamespace");
$myNamespace->doSomething((function($a) {
printf("%s%s", $a[0], $a[1]);
}));
file B.php
include "../virp/index.php";
$myNamespace = $app::virpspace("myNamespace");
$myNamespace->doSomething(["Hello, ", "Virp !"]);
Virp contains relatively little functions, but it does not need many to be effective. In fact, the core of Virp is only about 100 lines long !
Inits a new instance of virp.
The virp object is a singleton, this way one instance can govern your entire app.
Defines or calls a namespace with the name given. If a namespace with the given name does not exist, one will be made.
Virpspaces have inbuilt functions for dealing with databse connections. It has these to enforce the principle of having namespaces only dealing with one database at the time.