-
Notifications
You must be signed in to change notification settings - Fork 31
Core\App
Fariz Luqman edited this page Jun 27, 2016
·
5 revisions
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]);