-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServiceProvider.php
38 lines (32 loc) · 1 KB
/
ServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace PHPDX\Site\Router;
use FastRoute\Dispatcher;
use FastRoute\RouteCollector;
use League\Container\ServiceProvider\AbstractServiceProvider;
class ServiceProvider extends AbstractServiceProvider
{
protected $provides = [
Dispatcher::class
];
/**
* Use the register method to register items with the container via the
* protected $this->container property or the `getContainer` method
* from the ContainerAwareTrait.
*
* @return void
*/
public function register()
{
// Set up the router
$this->container->share(Dispatcher::class, function () {
return \FastRoute\simpleDispatcher(function(RouteCollector $routeCollector) {
return $this->routes($routeCollector);
});
});
}
protected function routes(RouteCollector $r)
{
$r->get('/', '\PHPDX\Site\Controller\HomeController::home');
$r->get('/events', '\PHPDX\Site\Controller\EventsController::events');
}
}