Good day. For the sake of self-education I decided to write my own framework, I encountered the following problem.
There is such a construction
$route = new Route(); $currentController = $route->getCurrentRoute(); spl_autoload_register(function () use ($currentController) { $controllerFileName = __DIR__ . '/../App/Controllers/' . $currentController['controller'].'Controller' . '.php'; if(file_exists($controllerFileName)) { include $controllerFileName; } }); $controllerName = $currentController['controller'].'Controller'; $controller = new $controllerName; I appeal in the browser to the root of the site. The DefaultController should start. However, the answer is an error:
Class 'DefaultController' not found in Core.php (23): Core \ Core-> activeController ()
controller code
<?php namespace App\Controllers; use \Core\View; use \Core\Controller; /** * Class Default * @package App\Controllers */ class DefaultController extends Controller { public function indexAction() { View::renderTemplate('Home/index.html'); } } What am I doing wrong?
$currentController['controller']what? - vp_arth