With this step we are going to create two new layers - application and views
project_folder
|_____config
| |_____Database.php
|
|_____core
| |_____Application.php
|
|_____service
| |_____PostService.php
|
|_____data
| |_____Post.php
|
|_____views
|
|__________app.php
|
|__________index.php
namespace core;
/**
* Description of Application
*
* @author Evgenia
*/
class Application {
const VIEWS_FOLDER = 'views';
public function load_view($templateName, $data = null)
{
include self::VIEWS_FOLDER
. '/'
. $templateName
. '.php';
}
}
session_start();
spl_autoload_register(function ($class_name) {
include $class_name . '.php';
});
$db = new \config\Database();
$app = new \core\Application();
This is index.php: