Setup the Front Controller

Navigate to my-project/public/index.php:

phpCopy code<?php

use Phalcon\Mvc\Application;
use Phalcon\Loader;
use Phalcon\Di\FactoryDefault;

try {
    // Register an autoloader
    $loader = new Loader();
    $loader->registerDirs([
        '../app/controllers/',
        '../app/models/',
    ])->register();

    // Create a DI (Dependency Injection) container
    $di = new FactoryDefault();

    // Handle the request
    $application = new Application($di);

    echo $application->handle()->getContent();
} catch (\Exception $e) {
    echo "PhalconException: ", $e->getMessage();
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *