-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
33 lines (26 loc) · 1.01 KB
/
index.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
<?php
use Framework\Router;
use Framework\Dispatcher;
use Illuminate\Container\Container;
use Illuminate\Contracts\Container\Container as ContainerInterface;
require_once('laravel-helper-override.php');
require_once('vendor/autoload.php');
$httpMethod = 'GET'; $defaultPath = '/users';
// Get the path from the arguments given
// in the CLI, or use the default path
$path = trim(array_get($argv, 1, $defaultPath), '/');
// Instantiate the DI container and
// make sure every time a class needs it,
// it gets this very instance of it.
$container = new Container;
$getContainer = function() use ($container) {return $container;};
$container->bind(ContainerInterface::class, $getContainer);
$container->singleton(Container::class, $getContainer);
// Get the framework-router and
// dispatcher from the container
$router = $container[Router::class];
$dispatcher = $container[Dispatcher::class];
// get route from the path and http-method
$route = $router->route($httpMethod, $path);
// dispatch the route
$dispatcher->dispatch($route);