The PHP framework that stays out of your way
Flexagon is a lightweight, high-performance PHP web framework. It embraces PHP's inherent simplicity over complex abstractions, keeping conventions to a minimum so you can build applications quickly.
composer create-project flexagon/skeleton myapp
<?php
// public/hello.php → https://example.com/hello
_Global::$SITE_TITLE = 'Hello';
TemplateLoader::show('head');
?>
<h1>Hello, Flexagon</h1>
<p>Pages are plain PHP files. Their path is their URL.</p>
<?php
TemplateLoader::show('tail');
- 0
- runtime dependencies
- 1.09ms
- framework bootstrap
- 2MB
- bootstrap memory
- 237KB
- single PHAR file
Design principles
If you know PHP, you can get started right away
Pages are .php files, views are written directly in PHP and HTML, and you can use the SQL you already know. There is no routing syntax, service container, or query DSL to learn before you start building.
Simple, flexible routing
The file structure maps directly to the URL structure, keeping routing intuitive and straightforward.
Independent request execution
Each request leaves no unnecessary state behind, keeping behavior stable and predictable.
Simple, idiomatic PHP
Build with PHP in its natural form, without introducing a separate template language.
Write less, know more
Code you can read at a glance
- URLs map directly to file paths. There is no routing table to maintain. The URL itself tells you which file will run.
- The database is the source of truth for the schema. A DAO reads column and primary-key metadata on its first query, so the schema is never duplicated in PHP.
- Global configuration stays explicit. Settings live in the static _Global class — no DI container between you and your configuration. Type _Global:: and let your IDE list them.
- Minimal overhead per request. Bootstrap defines constants, registers the autoloader and loads configuration. Nothing else is created until you ask for it.
<?php
namespace ExampleUser;
use _Flexagon\Base\BaseMySqlDAO;
class UserDAO extends BaseMySqlDAO {
protected string $tableName = 'users';
public function insert(UserModel $user): int|false {
return $this->_insert($user);
}
public function findById(int $id): ?UserModel {
return $this->_select(['id' => $id], new UserModel());
}
/** @return UserModel[] */
public function findByCity(string $city, int $page = 1): array {
return $this->_selectList(
new UserModel(), $page, 20,
'`address` = :CITY', ['CITY' => $city],
'`created_at` DESC'
);
}
}
<?php
namespace ExampleUser;
use _Flexagon\Base\BaseModel;
class UserModel extends BaseModel {
private ?int $id = null;
private string $name;
/** @encrypt */
private string $residentNumber = '';
public function getId(): ?int { return $this->id; }
public function setId(?int $id): void { $this->id = $id; }
public function getName(): string { return $this->name; }
public function setName(string $name): void { $this->name = $name; }
// Columns map to getters: resident_number → getResidentNumber()
}
<?php
use _Flexagon\Libs\Env;
use _Flexagon\Models\DataSourceModel;
// Secrets come from .env.php or the environment, never from this file.
_Global::$DATA_SOURCES['default'] = new DataSourceModel(
Env::get('DB_HOST', 'localhost'),
Env::int('DB_PORT', 3306),
Env::get('DB_USER'),
Env::required('DB_PASSWORD'),
Env::get('DB_NAME')
);
_Global::$SESSION_AUTO_START = true;
_Global::$SESSION_ENCRYPTION_STRING = Env::required('SESSION_ENCRYPTION_STRING');
Lightweight and fast
A light framework for fast web applications
In the same environment, Flexagon is ready for a request in 1.09 ms, using 2 MB of memory and 15 files. Laravel needs 12.85 ms, 20 MB and 336 files. Because the framework is this light and fast, you can expect the same good performance from the web applications you build on it.
It installs at 532 KB with no runtime dependencies, against Laravel's 42 MB and 77 packages, and deploys as a single 237 KB PHAR file. The target server needs neither Composer nor a cache-warming step.
| Flexagon 3.5.0 | Laravel 13.26.1 | |
|---|---|---|
| Runtime dependencies | 0 | 77 packages |
| Installed size | 532 KB | 42 MB |
| Bootstrap time | 1.09 ms | 12.85 ms |
| Bootstrap memory | 2 MB | 20 MB |
| Files loaded at bootstrap | 15 | 336 |
Batteries where they matter
Everything a web application needs, nothing it does not
Get started
From zero to a running page in three steps
Create a project
composer create-project flexagon/skeleton myapp
cd myapp
Add a page
<?php
// public/hello.php
TemplateLoader::show('head');
echo '<h1>Hello, Flexagon</h1>';
TemplateLoader::show('tail');
Run it
docker compose up -d
php script/flexagon.php check
# open http://localhost:8080/hello
Build with PHP, the way PHP was meant to be written.
Flexagon is free and open source under the MIT License.