Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
some commenting
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Hernandes committed Sep 24, 2016
1 parent 5007aaa commit 483fcb9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion start.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

require __DIR__.'/vendor/autoload.php';

// container instance
$container = \Sioc\Container::getInstance();

// create a database instance
$database = new \Demo\Database();

// register database as singleton that will resolve
// always the same instance
$container->register(\Demo\DatabaseInterface::class, new \Demo\Database());

// register \Demo\User on the alias user
$container->register('user', \Demo\User::class);

/** @var \Demo\User $user */
// Resolve the 'user'
$user = $container->make('user');

// show the user instance
var_dump($user);
// verify it's working
var_dump($user->getName());
// verify the database instance is the same on the singleton
var_dump($user->getDatabase() == $database);

0 comments on commit 483fcb9

Please sign in to comment.