Instantiate the app and load classes from any routed or included page.
app > pages
app > template
require_once(FILE_APP);
$app = new app();
$app->get("new_class")->hello();
Create new classes by file and folder creation within
back > app
class new_class {
public function hello(){
echo "Hello World!";
}
}
$app->get("class")->function();
Class interactions are implemented using dependency injections. Dependency injections are simply a method of giving a particular class access to another class and its methods.
All classes can get access to other classes by adding the following public class variables.
Name | Description |
---|---|
$inject | An array of classes to be included and automatically set as class variables |
$app | This variable will automatically set to the parent global dependency container. |
class util {
public function round($number){
return round($number);
}
}
//$inject example
class class1 {
public $inject = ["util"];
public function getNumber($number){
return $this->util->round($number);
}
}
//$app example
class class1 {
public $app;
public function getNumber($number){
return $this->app->get("util")->round($number);
}
}