-
Notifications
You must be signed in to change notification settings - Fork 11
Services
Devin Smith edited this page Jul 31, 2014
·
19 revisions
Tipsy uses Dependency Injection to allow easy access to services.
Allows access to the view renderer.
$tipsy->router()
->when('', function($View) {
$View->display('home');
});The scope of the view. All variables are passes by reference to allow two way data binding.
// Router PHP
$tipsy->router()
->when('chat', function($Scope, $View) {
$Scope->message = 'Hello!';
$View->display('chat'); // will output "<b>Hello!</b>"
echo $Scope->message; // will output "Goodbye!"
});// Chat PHTML
<b><?=$message?></b>
<? $message = 'Goodbye!'?>Direct access to the Tipsy object.
$tipsy->router()
->when('debug', function($Tipsy) {
var_dump($Tipsy->config());
});Direct access to the current route
$tipsy->router()
->when('debug', function($Route) {
var_dump($Route);
});Access to route params. Anything that starts with ":" will populate this service.
$tipsy->router()
->when('user/:id', function($Params) {
echo $Params->id;
});The HTTP request service. Access to request variables or JSON post data.
$tipsy->router()
->post('post', function($Request) {
var_dump($Request);
});- Home
- Getting Started
- Server Config
- Installation
- Installing Composer
- App
- Route Shorthand
- Config
- Routes
- Methods
- Controller Types
- Params & Regex
- Aliases
- Dependency Injection
- Advanced Routing
- Services
- User Defined Services
- Built in Services
- Middleware
- Views
- Templates
- Scope
- Resource
- Factory
- Looper
- Examples
- Plugins
- About