Example #1
0
 /**
  * Register classes in the container
  */
 protected function register()
 {
     $this->container->addServiceProvider(new CoreServiceProvider());
     $this->container->addServiceProvider(new ViewServiceProvider());
     $this->container->singleton(Pheanstalk::class, function () {
         return new Pheanstalk('127.0.0.1');
     });
 }
Example #2
0
 /**
  * {@inheritDoc}
  *
  * @throws ClassDoesNotImplementServiceProviderInterfaceException
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $dispatcher = $this->router->getDispatcher();
     $requestUri = parse_url($request->getRequestUri(), PHP_URL_PATH);
     $this->container->singleton(Request::class, $request);
     $this->boot();
     return $dispatcher->dispatch($request->getMethod(), $requestUri);
 }
Example #3
0
 private function buildContainer()
 {
     $self = $this;
     $this->container = new Container();
     $this->container->singleton(Config::class, function () use($self) {
         $filename = "{$self->dir}/config/config.php";
         $settings = file_exists($filename) ? include $filename : [];
         return new Config($settings);
     });
     $this->container->singleton(Engine::class, function () use($self) {
         return new Engine("{$self->dir}/templates");
     });
     $this->container->singleton(RouteCollection::class, function () use($self) {
         $router = new RouteCollection($self->container);
         $routerfile = "{$self->dir}/config/router.php";
         if (file_exists($routerfile)) {
             include $routerfile;
         }
         return $router;
     });
     $this->container->singleton(Emitter::class);
 }