Architecture
Which libraries Flute is built from, where things live in the site directory, and the main rule between the core and modules.
This page is for people writing a module or a theme: what Flute is built from, where things live and which rule between the core and modules you must not break. If you know Symfony and Laravel, most of the stack will look familiar.
Stack
| What | Built with |
|---|---|
| Routes and HTTP | Symfony Routing, HttpFoundation, HttpKernel 7.4. Routes are declared with #[Route] attributes on controller methods |
| Database | Cycle ORM with Active Record and migrations. MySQL, MariaDB or PostgreSQL |
| Templates | Blade from illuminate/view 12 |
| Styles | SCSS is compiled on the server with scssphp, no Node.js needed |
| Browser scripts | plain scripts without a build step and htmx for server-rendered fragments |
| Social sign-in | HybridAuth |
| Payments | gateways on a shared core contract, some of them on Omnipay |
| Cache | Symfony Cache: Redis, Memcached, APCu, files |
| Console | Symfony Console, commands run through php flute |
| Dependency container | PHP-DI 7 |
| Logs | Monolog 3 |
| HTTP client | Guzzle 7 |
| Symfony Mailer |
Flute had to patch a few packages for its own needs: Cycle ORM, Cycle Database, Cycle Entity Behavior, scssphp and Yoyo. Their copies live in packages/ and are wired in from the root composer.json.
How the site runs
- On regular hosting: a web server with PHP-FPM or the PHP module, site root in
public/. - In Docker: nginx and php-fpm in one container, plus the
cronandqueuecontainers (Installing with Docker). - In worker mode: FrankenPHP keeps the application loaded and serves many requests in a row with it. Only for sites without paid modules: ionCube Loader does not load into FrankenPHP.
- For development:
php flute servestarts a local server.
Site directory
app/
├── Core/ core: container, router, services, console
│ ├── Database/Entities/ Cycle ORM entities
│ ├── Modules/ built-in modules: Admin, Auth, Payments, Installer, Studio…
│ ├── Services/ core services: mail, encryption, cache…
│ └── ServiceProviders/ DI providers
├── Modules/ installed modules
├── Themes/ themes; the engine ships with standard
└── Helpers/ global helper functions
bootstrap/ application bootstrap, list of required PHP extensions
config/ default settings; the site saves its own here
config-dev/ local developer settings, not in git
i18n/ core translations, 15 languages
packages/ patched copies of third-party packages
public/ web server root, the only public folder
storage/ cache, logs, core migrations, backupsIn Docker the site keeps saved settings in storage/config instead of config/ (the FLUTE_CONFIG_DIR variable).
The main rule: the core knows nothing about modules
Dependencies go one way: modules and themes depend on the core, the core does not depend on them. In practice this means:
app/Corehas nouse Flute\Modules\…, no module name and no path to a module.- The core does not check which module or theme is installed. Instead of
if ($module === '…'), the core provides an extension point: an event, a registry, a contract or a container binding. The module registers itself there. - If only one module needs a feature, the feature lives in that module. The core gets only the extension point the module plugs it in through.
- Modules talk to each other through public
ServicesandContractsand declare the dependency inmodule.json.
Themes handle presentation only: a theme has no business logic, no routes and no database writes. How Flute finds a theme's templates and what a theme can override is covered in How themes work.
More on extension points and module structure: Modules.
Rules in the repository
Code rules live in AGENTS.md files across the engine repository. They are written for both people and AI agents and take precedence over any older document. Before you edit a file, open the AGENTS.md closest to it.
| File | What it covers |
|---|---|
AGENTS.md | repository map, commands, the core and modules rule |
app/AGENTS.md | PHP 8.2 level, style, KISS/DRY/SOLID, comments |
app/Core/AGENTS.md | container, providers, events, configuration, cache, extension point catalog |
app/Core/Router/AGENTS.md | attribute routes, middleware, HTTP |
app/Core/Api/AGENTS.md | public API: response format, scopes, keys, what breaks compatibility |
app/Core/Modules/Auth/AGENTS.md | sign-in, sessions, 2FA, sign-in confirmation, permission levels |
app/Core/Modules/Payments/AGENTS.md | invoices, gateways, idempotency, what must be atomic |
app/Core/Template/AGENTS.md | view lookup, how to write a theme, Blade rules, assets |
app/Core/UI/AGENTS.md | <x-*> components: contract, restrictions, list |
app/Core/Modules/Admin/AGENTS.md | admin panel: pages, tables, forms, actions, permissions |
tests/AGENTS.md | how to check a change, what CI checks |
docs/ui-playbook/ | page types, screen states, tables, forms, interface copy |
docs/module-guide.md | a module from scratch: from module.json to an admin screen |