Skip to content

Core\App

Fariz Luqman edited this page Jun 27, 2016 · 5 revisions

The Application container

The application container or the App container is a tool used for dependency injection. Dependency injection is a method for writing better code. For simplicity, the application container will link any variables or objects using the method Core\App::link().

Say that you have database service:

// returns the Illuminate\Database\Capsule\Manager into $database
$database = Core\Database::connect();

Link them with the App container

$app->link('database', $database);

And then use it in the template files or anywhere

$users = $app->database->select('select * from users where id = :id', ['id' => 1]);

Visit our website for tutorials: stupidlysimple.github.io

Clone this wiki locally