Skip to content

Dependency Injection

Devin Smith edited this page Dec 10, 2015 · 3 revisions

Tipsy allows easy reference of a bunch of different services and models used within itself using Dependency Injection.

Services

For a list of all available services, see Services.

$tipsy->router()
	->when('user/:id', function($Params, $Scope, $View) {
		$Scope->user = $Params->id;
		$View->display('home');
  });

Class reference

// Define the User
$tipsy->service('User', [
	sup => function() {
		return 'Sup '.$this->user;
	}
]);

// Set the route
$tipsy->router()
	->when('user', function($User) {
		echo $User->sup();
	});