Skip to Content
Basics

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

WhatBuilt with
Routes and HTTPSymfony Routing, HttpFoundation, HttpKernel 7.4. Routes are declared with #[Route] attributes on controller methods
DatabaseCycle ORM with Active Record and migrations. MySQL, MariaDB or PostgreSQL
TemplatesBlade from illuminate/view 12
StylesSCSS is compiled on the server with scssphp, no Node.js needed
Browser scriptsplain scripts without a build step and htmx for server-rendered fragments
Social sign-inHybridAuth
Paymentsgateways on a shared core contract, some of them on Omnipay
CacheSymfony Cache: Redis, Memcached, APCu, files
ConsoleSymfony Console, commands run through php flute
Dependency containerPHP-DI 7
LogsMonolog 3
HTTP clientGuzzle 7
MailSymfony 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 cron and queue containers (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 serve starts 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, backups

In 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/Core has no use 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 Services and Contracts and declare the dependency in module.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.

On this page