Search by

phil / microsymfony

philSocolin

Start a Symfony app without a database, on FrankenPHP, with Castor tasks and every quality gate already passing.

8.2.0 2026-11-29 00:02 UTC

README

Latest Version PHP Version Require Symfony Version Symfony Style PHPStan level Software License Build Status (GitHub)

About ๐Ÿ–‹

MicroSymfony is a Symfony 8.2 application template on steroids, ready to use: a sandbox with sensible defaults, tests of every kind and strict quality gates, to start a proof of concept, try an idea or build a small application. It stays micro: no database, English and French pages, and nothing a small application does not need. Doctrine comes with WebSymfony, the next template up.

This template is the PHIL version of strangebuzz/MicroSymfony, created and maintained by COil of Strangebuzz. It keeps its name, its features and its spirit, and follows its releases. What differs, and why, is listed in Differences from strangebuzz/MicroSymfony. The philosophy behind the template is explained by its author:

Table of Contents ๐Ÿ“–

Demo ๐ŸŒˆ

A live demo is always better than an explanation:

Quick-start โšก

Create a new project from the latest release:

composer create-project phil/microsymfony my-project && cd my-project

The repository is also a GitHub template repository: the "Use this template" button creates a new repository from the main branch, whose commits all pass the continuous integration.

With the Symfony binary ๐ŸŽถ

You need the Symfony binary and Castor:

castor start

Open https://127.0.0.1:8000 (if port 8000 is free). castor stop stops the server.

With FrankenPHP ๐ŸงŸ

You need Docker. compose.yaml serves the application with FrankenPHP in worker mode, which boots the kernel once and serves request after request, and restarts its workers when a file changes:

castor up

Open https://localhost. castor down stops the service. The image of docker/Dockerfile is for development: an application deployed from this template brings its own deployment.

Requirements โš™

Stack ๐Ÿ”—

Features ๐Ÿš€

  • Tasks run by Castor (source, output): the common tasks of phil/dev-tools, imported from vendor/, and the template's own servers and environments
  • Static analysis with PHPStan 2 at the maximum level, with the strict, deprecation, Symfony and PHPUnit rules (configuration)
  • Coding standards with PHP-CS-Fixer, Twig-CS-Fixer and Biome for the Stimulus controllers
  • Tests of every kind, with one example each:
  • Code coverage at 100 % (the threshold is the coverage_threshold setting of PHIL_CASTOR in castor.php)
  • A GitHub Actions workflow: security, tests on PHP 8.5 and 8.6, lints
  • Pages in English and in French: the layout, the menu and the footer read their texts from translations/, and the home page shows the README of the language the browser prefers
  • AssetMapper and Stimulus: a vanilla controller (source) and one that fetches JSON from an endpoint of the application (source)
  • A custom error template (source)

Tasks ๐Ÿงฐ

castor lists every task. The main ones:

Task What it does
castor start, castor stop The Symfony binary's web server.
castor up, castor down FrankenPHP in worker mode, with Docker Compose.
castor test Every PHPUnit suite but E2E; --filter and --options pass on to PHPUnit.
castor test:unit, test:integration, test:api, test:functional One suite.
castor test:e2e The E2E suite in a real browser, Chrome driven by Panther: it types a title on the Stimulus page and waits for the slug the api controller fetches. Chrome and chromedriver must be on the PATH, or let vendor/bin/bdi detect drivers download the driver into drivers/ after composer require --dev dbrekelmans/bdi. Neither castor test, castor coverage, castor ci nor the continuous integration runs it.
castor test:suite <name> One suite of phpunit.dist.xml, by its name.
castor test:next The tests on the next PHP version, in its Docker image.
castor coverage The HTML coverage report in var/coverage/, and its threshold.
castor infection Mutation testing.
castor taint The taint analysis of Psalm.
castor lint Every lint and the static analysis.
castor fix Rector, PHP-CS-Fixer, Twig-CS-Fixer, Biome and composer-normalize.
castor ci The continuous integration, locally: coverage, then every lint.
castor hooks The git hooks: the fast checks on the staged files before each commit.

Every task but the servers, go-prod, go-dev, purge and check-requirements comes from phil/dev-tools: castor.php imports vendor/phil/dev-tools/resources/castor/tasks.php and sets the suites and the coverage threshold in its PHIL_CASTOR constant; E2E is left out of its suites. A task of the application's own is added to castor.php under a name of its own, and named in the test_also, lint_also, fix_also or ci_also setting to run with the aggregate tasks; the tasks and settings are described in vendor/phil/dev-tools/doc/castor.md.

Quality gates ๐Ÿšฆ

The checks come from phil/dev-tools, the shared tooling of PHIL, adapted to an application. Each tool is installed in its own vendor-bin/<tool>/ directory by the Composer bin plugin, so that its dependencies never meet the application's. The thin configuration files at the root (phpstan.neon, rector.php, .php-cs-fixer.dist.php, arkitect.php) call the shared ones; phil-dev.php holds what is particular to the application, each exception with its reason.

Task Checks
castor lint:composer The dependency analysis (a class used without its package required), composer audit, composer-unused and composer-normalize.
castor lint:php PHP-CS-Fixer: @Symfony, @Symfony:risky, strict types and strict comparisons.
castor lint:twig lint:twig, then the code style of the templates.
castor lint:js Biome on the Stimulus controllers.
castor lint:yaml, lint:container The YAML files, the messages included, and the container.
castor stan PHPStan at the maximum level, with type coverage at 100 %, a cognitive complexity limit and forbidden calls.
castor lint:rector Rector has nothing left to change.
castor lint:architecture Arkitect on the shape of the classes; Deptrac on the libraries src/ may use, listed in phil-dev.php.

The taint analysis of Psalm, castor taint, runs on its own, before a release and once a week: it follows what comes from a request, a file or the environment to an HTML page, a shell, a file path or unserialize(). The .github/ directory also holds the security files of phil/dev-tools: Dependabot, with a cooldown of seven days, the OpenSSF Scorecard and zizmor, which audits the workflows.

Differences from strangebuzz/MicroSymfony ๐Ÿ”€

This template follows the releases of strangebuzz/MicroSymfony. It differs where the principles of PHIL ask for it:

strangebuzz/MicroSymfony This template Why
The latest stable Symfony Symfony 8.2, and the next minor version from its first release candidate, minimum-stability at beta PHIL tests on the next Symfony as soon as its release candidate is out. Symfony tags only the components that changed since the last beta, so beta is the lowest stability that installs a release candidate; prefer-stable takes the stable releases first.
PHP 8.4 or later PHP 8.5 or later The floor of every PHIL package and template; the continuous integration also runs the next PHP.
Configuration in PHP, with the array shapes of App::config() Configuration in YAML: config/packages, routes and services The format of the Symfony documentation and of the Flex recipes, with when@env blocks; config/bundles.php and config/preload.php stay PHP.
Make and Castor Castor only, no task script in composer.json One task runner, written in PHP; Composer stays a dependency manager.
PHPStan and PHP-CS-Fixer, Biome through a bundle The gates of phil/dev-tools: PHPStan with its extensions, Rector, Arkitect, Deptrac, Twig-CS-Fixer, Biome, the dependency analysis, composer-unused, composer-normalize, CaptainHook, Infection The checks every PHIL repository passes, so that an application starts at the same bar.
PHPUnit tests, coverage metadata optional #[CoversClass] or #[CoversNothing] required, deprecations, notices and warnings fail Coverage counts only what a test sets out to test, and a deprecation is fixed before the next version removes it.
Doctrine ORM on SQLite, a User entity and Foundry No database A micro application needs none; WebSymfony brings Doctrine.
Pages in English Pages in English and in French, chosen from the browser's languages PHIL publishes in both languages.
No error tracking Sentry in the production environment, off while SENTRY_DSN is empty An application in production reports its errors from its first deployment.
A FrankenPHP demo with docker run compose.yaml with FrankenPHP in worker mode One command for the production-like setup; the Symfony binary stays the light choice.
Deployment tasks, Apache configuration, Scrutinizer None A template holds no deployment: each application brings its own.
A procedure to downgrade to Symfony 7.4 LTS None PHIL supports the latest Symfony only.
Exit codes of the aggregate tasks summed Exit codes reduced to 0 or 1 A shell keeps exit codes modulo 256: a sum of 256 reads as a success.

Besides those, the template keeps the PHIL identity: its name, its logo as the favicon and its copyright. The template requires no PHIL package at run time: phil/dev-tools is a development dependency only, and the application stays micro.

Notes ๐Ÿ“’

Symfony UX

Turbo forms are disabled in assets/app.js. To enable them for a form, add the data-turbo="true" attribute to it, or set Turbo.setFormMode to on to enable them everywhere. In both cases, the controller has to be adapted.

YAML configuration files

The configuration of Symfony and of the bundles is in YAML, under config/: config/packages/*.yaml, with when@dev, when@test and when@prod blocks for what changes by environment, config/routes.yaml, config/routes/*.yaml and config/services.yaml. A Flex recipe adds its files in the same format. Only config/bundles.php and config/preload.php stay PHP. castor lint:yaml checks every file of config/, and castor lint:container checks the container they build.

# config/packages/framework.yaml
framework:
    default_locale: en
    enabled_locales: [en, fr]
    set_locale_from_accept_language: true

Languages

The pages are in English, the default locale, and in French: config/packages/framework.yaml enables both, and a browser whose Accept-Language header prefers French gets the French pages, on the same addresses. The messages are in translations/; a new visible text gets its key in both files.

Sentry

In the production environment, the errors go to Sentry once SENTRY_DSN holds the DSN of your project, set as a real environment variable or a secret, never in a committed file. While it is empty, as in .env, nothing is sent. The configuration is in config/packages/sentry.yaml.

A database

MicroSymfony has none. For Doctrine, start from WebSymfony, or add it with composer require symfony/orm-pack.

Other good practices ๐Ÿ‘Œ

ADR ๐Ÿ“

Architecture Decision Records of strangebuzz/MicroSymfony; this template keeps every one but the one on Doctrine and the two on PHP configuration:

  • [2026-01-17] Use Doctrine ORM as the default database layer (PR)
  • [2025-12-29] Use the new PHP configuration (PR)
  • [2025-01-25] Include the FrankenPHP runtime by default (PR)
  • [2025-01-21] Add PHPUnit test suites (PR)
  • [2024-12-18] Use PicoCSS instead of BareCSS as the CSS framework (PR)
  • [2024-12-05] Convert all configuration files to PHP (fluent interface) (PR)
  • [2024-09-22] Use the ADR pattern for all controllers (PR)

Those of this template:

  • [2026-11-25] Symfony 8.2 from its release candidate, PHP 8.5, the gates of phil/dev-tools, Castor only, FrankenPHP in worker mode in compose.yaml
  • [2026-11-25] No database: Doctrine moves to WebSymfony; pages in English and in French; Sentry in production
  • [2026-11-26] The configuration in YAML: config/packages, routes and services
  • [2026-11-26] The common Castor tasks of phil/dev-tools imported by castor.php; the route smoke test of phil/dev-tools; every requirement at its latest minor release

What it doesn't ship? โŒ

  • Doctrine and a database: start from WebSymfony (phil/websymfony), MicroSymfony with Doctrine

PHIL bundles ๐Ÿงฉ

The bundles of PHIL add what an application needs, one at a time, with composer require. A few that suit a small application:

The PHIL organization on GitHub lists every package.

References ๐Ÿ“š

Others โ€œProclaim Honestly, Interact Liberallyโ€ Skeletons ๐Ÿฉป

  • WebSymfony (phil/websymfony)

    • MicroSymfony +
    • A database
      • Doctrine ORM and its migrations
      • StofDoctrineExtensionsBundle
    • Still Pico CSS, with Stimulus and Turbo
    • EasyAdmin
    • KnpMenuBundle
    • Security layers
      • Symfony Security
      • NelmioSecurityBundle
      • NelmioCorsBundle
    • Sentry
    • and more.
  • WebSkeleton (phil/webskeleton)

  • ApiSymfony (phil/apisymfony)

    • API Platform
    • The same tasks, run by Castor
    • Static analysis with PHPStan
    • Coding standards with PHP-CS-Fixer
    • Refactoring with Rector
    • Tests: unit, API and end-to-end
    • GitHub CI
    • Symfony Maker

Contributing ๐Ÿค

See CONTRIBUTING and the Code of Conduct.

Security ๐Ÿงฏ

See SECURITY.

Credits ๐Ÿ™

License โš–๏ธ

The MIT License, with the attribution to the original repository it asks for. See the license file.

Built with MicroSymfony ๐Ÿ› ๏ธ

  • WebSymfony, which lists what is built with it, starting with WebSkeleton.