Is my first MVC architecture set up to standards? I just started learning about the MVC architecture. And I started to create my own MVC framework to how I like it the most.

Here I've got the index.php, indexcontroller.php and view.php. I'm not too sure if what I am doing is right, or with best practices. So I would like to know if there is anything I missed so far, or what I could improve?

Index.php (updated)

//report all php errors
error_reporting(E_ALL);

//define site root path
define('ABSPATH', dirname(__FILE__));

//include functions
foreach(glob(ABSPATH . '/functions/*.php') as $filename) {
    require $filename;
}

//set config array
$config = parse_ini_file(ABSPATH . '/config.ini', true);
$config = json_decode(json_encode($config));

//auto load classes
spl_autoload_register('autoloadCore');
spl_autoload_register('autoloadController');
spl_autoload_register('autoloadModel');

//url to class router
Glue::stick((Array) $config-&gt;routes);


IndexController

class IndexController extends BaseController {
    private $_view;

    public function GET() {
        $this-&gt;index();
    }

    public function POST() {
        //don't handle post
    }

    public function __construct() {
        $this-&gt;_view = new View();
    }

    public function index() {
        $this-&gt;_view-&gt;welcome = 'Welcome!';
        $this-&gt;_view-&gt;render('index');
    }
}


View

class View {
    private $_vars = [];

    public function __set($index, $value) {
        $this-&gt;_vars[$index] = $value;
    }

    function render($fileView) {
        $path = ABSPATH . '/view/' . $fileView . '.php';
        if(!file_exists($path)) {
            throw new Exception('View not found: '. $path);
        }
        foreach($this-&gt;_vars as $key =&gt; $value) {
            $$key = $value;
        }
        include ($path);               
    }
}
MVC approaches differ between languages, platforms and frameworks. They are usually termed "MV* frameworks" because they don't exactly follow strict MVC. But we call them MVC nonetheless.

Separate core logic from configurable logic

The way I understand your code, it looks like you've gone over CodeIgniter (or something similar). I assume all your requests run through index.php where the initial logic runs, like the helper loading, routing etc. For that, I suggest you separate the autoloader list and routing list to different files. You can load them via something like include. That way, you don't accidentally modify the core logic.

// autoload.php
$autoload = array(
  'autoloadCore',
  'autoloadController',
  'autoloadModel'
);

// routes.php
$routes = array(
  '/'       =&gt; 'Index',
  '/signup' =&gt; 'SignUp',
  '/login'  =&gt; 'Login'
);


Additionally, the word "Controller" might not be necessary for the routing. You already know that they always go to controllers. You might want to do that in the underlying logic instead, and keep it easy on the configurable parts.

Route lists cons

One thing to note with this routing strategy is that whenever you add a controller, you always need to list down the route. This approach is not that nice, especially when you are going to be handling a hundred routes (and trust me, it ain't a walk in the park).

Auto-route + custom routes

Why not automatically look for controllers based on a predefined convention (like CodeIgniter). A route of /foobar/bam would route to FoobarController and execute the bam method. As for custom routes, you can map it like so:

$routes = array(
  'autobam' =&gt; 'foobar/bam` // A route of `/autobam` executes the same as `foobar/bam`
);


And the flow goes like:

- Parse route
- Check for match under custom
  - If match, convert to equivalent route
- Use non-custom/equivalent route for locating the controller
  - If none, throw error
  - Else, load and execute