Простая реализация MVC Архитектуры на PHP.
How to use:
'blog'=>[
'controller' => 'blog',
'action' => 'index'
],
'post'=>[
'controller' => 'blog',
'action' => 'show'
]
namespace app\controllers;
use core\Controller;
class Blog_Controller extends Controller
{
public function index_action(){
$this->view->render('index');
}
public function show_action(){
$data = $this->model->get_posts();
$vars = [
'posts'=> $data
];
$this->view->render('show', $vars);
}
}
namespace app\model;
use core\Model;
class Blog_model extends Model {
public function get_posts(){
$result = $this->db->row('SELECT title, content FROM posts');
return $result;
}
}
-
- view
- blog
index.php
show.php
- blog
- view