SPECS


Phalcon


The Phalcon MVC Framework


For full documentation visit phalcon.io.


Over 10 Years | Multiple Projects | Preferred


Phalcon is a full-stack PHP framework delivered as a C-extension, which loads directly into RAM as a PHP module to provide unmatched execution speed and low resource consumption. Unlike standard frameworks, you do not download massive core PHP files. Instead, you interact directly with high-performance C-optimized classes exposed right inside your PHP environment.


  • 1. Directory Structure

A standard Model-View-Controller (MVC) project layout in Phalcon separates public assets from your core application logic:

my-phalcon-app/
├── app/
│   ├── controllers/
│   │   └── IndexController.php
│   ├── models/
│   └── views/
│       └── index/
│           └── index.phtml
└── public/
    └── index.php


  • 2. The Bootstrap File (public/index.php)

The bootstrap file serves as the universal entry point for your application. It initializes the autoloader, configures dependency injections (DI), handles requests, and returns responses.

<?php
// public/index.php
use Phalcon\Loader;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;

try {
    $loader = new Loader();
    $loader->registerDirs(['../app/controllers/'])->register();
    $di = new FactoryDefault();
    $di->set('view', function () {
        $view = new View();
        $view->setViewsDir('../app/views/');
        return $view;
    });
    $application = new Application($di);
    echo $application->handle($_SERVER['REQUEST_URI'])->getContent();
} catch (\Exception $e) {
    echo "Exception: ", $e->getMessage();
}


  • 3. The Controller (app/controllers/IndexController.php)

Phalcon maps request paths to controllers and actions.

<?php
// app/controllers/IndexController.php
use Phalcon\Mvc\Controller;
class IndexController extends Controller {
    public function indexAction() {
        $this->view->setVar('name', 'Developer');
    }
}


  • 4. The View (app/views/index/index.phtml)

Views are rendered based on controller naming conventions.

<h1>Hello, <?php echo $name; ?>!</h1>


How to Run

  • Install: Enable the PHP Phalcon extension.

  • Config: Point web server to the public/ directory.

  • Run: Use php -S localhost:8000 -t public/


Very quick to setup a new project with!


Phalcon is among the original MVC frameworks. There are no special commands as in other PHP based frameworks, but projects are still very quick to build out and customize.


There are dozens of readily maintained Docker Containers already setup and ready to go on Docker Hub.


Development Frameworks


JS Frameworks


CSS Frameworks


More Frameworks



Social Media




---
title: Phalcon
text: The Phalcon MVC Framework
image: /assets/svg/phalcon.svg
link: 
target: 
---