-
Notifications
You must be signed in to change notification settings - Fork 10
User Defined Services
Devin Smith edited this page Dec 10, 2015
·
4 revisions
Services in Tipsy are static objects. They are accessible in the same ways as Built in Services. Services can be arrays, closures, classes or class instances.
$tipsy->service('Service', [
stuff => function() {
// some stuff
}
]);
Using a closure allows for the use of Dependency Injection as you can see with this $View
example.
$tipsy->service('Service', function($View) {
$service = [
stuff => function() use ($View) {
// some stuff
}
];
return $service;
);
class Service extends Tipsy\Service {
public function stuff() {
// stuff
}
}
$tipsy->service('Service');
class Service extends Tipsy\Service {
public function stuff() {
// stuff
}
}
$tipsy->service('Service', new Service);
$tipsy->service('Service', new class() extends Tipsy\Service {
public function stuff() {
}
});
- 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