Update Framework
This commit is contained in:
parent
06f17dff5b
commit
69f3313f0f
19 changed files with 974 additions and 35 deletions
47
src/Runtime/Factory/BootstrapFactory.php
Normal file
47
src/Runtime/Factory/BootstrapFactory.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Runtime\Factory;
|
||||
|
||||
use ClassNotFoundException;
|
||||
use Pecee\SimpleRouter\SimpleRouter;
|
||||
use Runtime\Exceptions\ExceptionHandler;
|
||||
|
||||
class BootstrapFactory {
|
||||
|
||||
public function handle()
|
||||
{
|
||||
SimpleRouter::setDefaultNamespace('\App\Http\Controllers');
|
||||
|
||||
require_once('../routes/web.php ');
|
||||
|
||||
try {
|
||||
SimpleRouter::start();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
ExceptionHandler::make($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $abstract
|
||||
* @return mixed
|
||||
*/
|
||||
public function make($abstract)
|
||||
{
|
||||
return $this->resolve($abstract);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $abstract
|
||||
* @return mixed|null
|
||||
*/
|
||||
private function resolve($abstract) {
|
||||
if(class_exists($abstract)) {
|
||||
return new $abstract;
|
||||
}
|
||||
|
||||
ExceptionHandler::make(ClassNotFoundException::class);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue