fix errore caricamento classe (parte 89)
| | |
| | | |
| | | $container = new Framework\Container; |
| | | |
| | | $database = new App\Database("localhost", "product_db", "product_db_user", "secret"); |
| | | $container->set(App\Database::class, $database); |
| | | |
| | | $dispatcher = new Framework\Dispatcher($router, $container); |
| | | |
| | | $dispatcher->handle($path); |
| | |
| | | use ReflectionClass; |
| | | |
| | | class Container { |
| | | |
| | | private array $registry = []; |
| | | |
| | | public function set(string $name, $value) { |
| | | $this->registry[$name] = $value; |
| | | } |
| | | public function get(string $class_name):object { |
| | | if(array_key_exists($class_name, $this->registry)) { |
| | | return $this->registry[$class_name]; |
| | | } |
| | | $reflector = new ReflectionClass($class_name); |
| | | $contructor = $reflector->getConstructor(); |
| | | |