There is such code:
index.php:
<?php // Подключаем загрузчик приложений в единую точку входа require_once 'app/load.php'; ?>
routing.php:
<?php class Routing { static function execute() { // контроллер и действие по умолчанию $controller_name = 'Main'; $action_name = 'index'; $routes = explode('/', $_SERVER['REQUEST_URI']); $model_name = 'Model_'.$controller_name; $controller_name = 'Controller_'.$controller_name; $action_name = 'action_'.$action_name; $controller_file = strtolower($controller_name).'.php'; $controller_path = "core/".$controller_file; if(file_exists($controller_path)) { include $controller_path; } // создаем контроллер $controller = new $controller_name; $action = $action_name; } } ?>
load.php:
<?php require_once 'core/routing.php'; require_once 'core/model.php'; require_once 'core/view.php'; require_once 'core/controller.php'; //Запуск роутинга Routing::execute(); ?>
controller.php:
<?php class Controller { public $model; public $view; function __construct() { $this -> view = new View(); } } ?>
controller_main.php:
<?php class Controller_Main extends Controller { function action_index() { $this -> view -> generate('fgdfgdfgdfg', 'template.php'); } } ?>
view.php:
<?php class View { function generate($content, $template, $data = null) { include 'app/views/template.php'; } } ?>
template.php:
<?php echo $content; ?>
The problem is that it is not clear how to display the text correctly. It is now empty.