Search by

phil / websymfony

philSocolin

A Symfony web application template built on MicroSymfony: accounts, security headers, an administration, Pico CSS, tests and quality gates.

8.2.0 2026-11-29 00:02 UTC

This package is auto-updated.

Last update: 2026-12-05 04:28:24 UTC


README

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

About ๐Ÿ–‹

โ€œProclaim Honestly, Interact Liberallyโ€ WebSymfony is a Symfony 8.2 web application template on steroids, ready to use: everything MicroSymfony gives, plus what a web site needs from its first day โ€” member accounts, security headers, an administration, a menu, English and French โ€”, with the same tests and quality gates.

WebSymfony is built on MicroSymfony, the PHIL version of strangebuzz/MicroSymfony, created and maintained by COil of Strangebuzz. It keeps its name, its layout, its look (Pico CSS) and its spirit. It uses no PHIL package at run time: the PHIL tools โ€” the PHIL UX kit, phil-ux and the PHIL bundles โ€” start with WebSkeleton.

Table of Contents ๐Ÿ“–

Documentation

Document What it covers
Extension points What an application built from the template changes first: the accounts, the pages and the menu, the administration, the security headers, the tasks and the exceptions to the gates.

The tasks and the quality gates are described in vendor/phil/dev-tools/doc/, once the dependencies are installed.

Demo ๐ŸŒˆ

A demo of WebSymfony will run in the browser on ph-il.ca, with the other templates of PHIL.

Quick-start โšก

Create a new project from the latest release:

composer create-project phil/websymfony 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. The database is a SQLite file in var/:

castor start

Open https://127.0.0.1:8000 (if port 8000 is free). The fixtures create two accounts: admin (password admin-password), which reaches the administration, and member (password member-password); never load them where the site is public. castor stop stops the server and deletes the database.

With FrankenPHP and PostgreSQL ๐ŸงŸ

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; the database is PostgreSQL 17:

castor up

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

With MySQL ๐Ÿฌ

MySQL is the other database the template supports. In compose.yaml, replace the database service with a mysql:8.4 image and set DATABASE_URL to:

mysql://app:app@database:3306/app?serverVersion=8.4&charset=utf8mb4

With the Symfony binary, set the same variable in .env.local, with the host of your server. The migration is written in the SQL of the database it runs on, so it needs no change.

Requirements

Stack ๐Ÿ”—

What it adds to MicroSymfony ๐Ÿš€

Feature Where
Sign-up, sign-in and sign-out, an account page src/Controller/Security, AccountAction
Users with hashed passwords and roles, ROLE_ADMIN above ROLE_USER User, security.yaml
Entities found wherever they live in src/, with no mapping to write, by auto_discover_entities doctrine.yaml
An administration for ROLE_ADMIN, with the list of users src/Controller/Admin
Security headers and a Content Security Policy with a nonce, by NelmioSecurityBundle nelmio_security.yaml
Cross-origin requests on /api/ only, by NelmioCorsBundle nelmio_cors.yaml
A main menu built by KnpMenu MainMenuBuilder
English and French, chosen from the browser's language translations, translation.yaml
Dates set by the Timestampable extension stof_doctrine_extensions.yaml
Errors sent to Sentry in production, when SENTRY_DSN is set sentry.yaml
The PHIL identity: logo, copyright, light and dark themes base.html.twig

Everything MicroSymfony has stays: the examples, the five test suites, Castor, the quality gates, Docker Compose.

Accounts and security ๐Ÿ”

  • Passwords are hashed by the auto hasher; the session keeps a crc32c of the hash, never the hash, so a changed password still signs the other sessions out.
  • The firewall checks the user again each time it is refreshed from the session (user_checker_on_refresh): a disabled or changed account is signed out on its next request.
  • The sign-in, the sign-up and the sign-out carry a CSRF token; the sign-out is a POST.
  • Five failed sign-ins a minute per user name and IP address, through login_throttling.
  • Impersonation is off; when it is turned on, only by POST with a CSRF token.
  • /account asks for ROLE_USER, /admin for ROLE_ADMIN.

Tasks ๐Ÿงฐ

castor lists every task. The main ones:

Task What it does
castor start, castor stop The Symfony binary's web server with SQLite, its migrations and its fixtures.
castor up, castor down FrankenPHP in worker mode and PostgreSQL, with Docker Compose.
castor load-fixtures The SQLite database reset, migrated and filled.
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 proves that the JavaScript of the pages runs under the Content Security Policy. 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 test:schema The migrations on a fresh SQLite database, then its schema compared with the Doctrine mapping.
castor coverage The HTML coverage report in var/coverage/, and its threshold.
castor infection Mutation testing.
castor taint The taint analysis of Psalm: no untrusted input reaches HTML, SQL, a shell or a file unescaped.
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, every lint, then test:schema.
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, load-fixtures, test:schema, lint:doctrine and check-requirements comes from phil/dev-tools: castor.php imports vendor/phil/dev-tools/resources/castor/tasks.php and sets the suites, the coverage threshold of 100 % and the YAML paths in its PHIL_CASTOR constant, where lint_also adds lint:doctrine to castor lint and ci_also adds test:schema to castor ci. 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.

The functional suite holds RouteSmokeTest, from Phil\DevTools\Testing\RouteSmokeTesting: every GET route answers under 500, a new route included as soon as it exists. A route whose parameters have no default is left out, unless smokeRouteParameters() gives values for them.

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, lint:doctrine The YAML files (config/ among them), the container and the Doctrine mapping.
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.

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/security.yaml
security:
    role_hierarchy:
        ROLE_ADMIN: [ROLE_USER]
    access_control:
        - { path: ^/admin, roles: ROLE_ADMIN }
        - { path: ^/account, roles: ROLE_USER }

What it doesn't ship ๐Ÿ™…

  • No deployment file: each application brings its own.
  • No PHIL package at run time: the PHIL UX kit, phil-ux and the PHIL bundles come with WebSkeleton.
  • No e-mail: the sign-up asks for no confirmation and there is no password reset; add symfonycasts/verify-email-bundle and symfonycasts/reset-password-bundle when the site sends mail.

References ๐Ÿ“š

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

  • MicroSymfony (phil/microsymfony): the micro template WebSymfony is built on, with no database, Pico CSS, Stimulus and Turbo, Castor, the tests and quality gates.
  • WebSkeleton (phil/webskeleton): WebSymfony and the PHIL tools, organised in DDD (Domain, Application, Infrastructure):
    • the PHIL UX kit for the Symfony UX Toolkit and phil/ux-css, the phil-ux stylesheet;
    • PHIL bundles: phil/ddd-bundle, phil/doctrine-behaviours-bundle, and, by a documented step, phil/identity-client-bundle for member accounts and phil/ux-easyadmin-bundle for an administration in the colours of PHIL UX;
    • French and English, routes prefixed /fr and /en, French by default.
  • ApiSymfony (phil/apisymfony): an API with API Platform, Castor, the tests and quality gates.

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: ยฉ Strangebuzz.com, and ยฉ Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See the license file.

Built with WebSymfony ๐Ÿ› ๏ธ