-
Notifications
You must be signed in to change notification settings - Fork 31
Core\App
Fariz Luqman edited this page Jun 29, 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);
To access the linked objects / variables in the container:
$users = $app->database
->table('users')
->where('id','1')
->get();
To access the container within any other defined scopes, the container will need to be "shared". Read about Core\Sharer.