A full-stack PHP framework delivered as a C extension.
Its innovative architecture makes Phalcon the fastest PHP framework ever built. You do not need to know C to use
it: the API is plain PHP classes in the
Phalcon\ namespace. Prefer no extension at all?
The same API ships as pure PHP.
Phalcon uses less memory and CPU than traditional frameworks, because the framework is already compiled and loaded
before the first request arrives.
How a request reaches your codeextension: load once ↻ every request
PHP STARTS
server boots
EXTENSION
loaded once
REQUEST
incoming HTTP
COMPILED CLASSES
ready in memory
RESPONSE
emit output
Zephir/C extensions load together with PHP, one time, when the web server daemon starts.
The classes and functions of the extension are ready for every application.
The code is compiled for the platform and processor, so it is not interpreted.
Thanks to this low-level architecture and its optimizations, Phalcon has the lowest overhead for MVC-based applications.
The tradeoff, stated plainly
Phalcon v6 gives up the raw speed of the compiled extension. In return, there is nothing to install or compile: it
runs on any host with PHP 8.1+, and every method is readable in your vendor directory.
Real code, not a fake terminal
The same framework, top to bottom.
Everything a full-stack app needs, organized the same way as the docs. Pick a layer. This code runs on v5 and v6.
A whole app in a handful of lines. The Micro application and the DI container are the same primitives that scale up to a full MVC stack.
index.php
use Phalcon\Http\Response;use Phalcon\Mvc\Micro;$app = new Micro();$app->get('/hello/{name}', function ($name) { return new Response("Hello, {$name}!");});$app->handle($_SERVER['REQUEST_URI']);
Cross-cutting services (logging, caching, config, security) register in the DI container and resolve lazily, once.
services.php
use Phalcon\Di\FactoryDefault;use Phalcon\Logger\Adapter\Stream;use Phalcon\Logger\Logger;$di = new FactoryDefault();$di->setShared('logger', function () { $adapter = new Stream('php://stderr'); return new Logger('messages', ['main' => $adapter]);});