phil / incident-mode-bundle
phil/incident-mode in Symfony: pause sign-ups, invitations or forms during an attack, with an honest public notice and automatic lifting.
Package info
github.com/parler-haut-interagir-librement/incident-mode-bundle
Type:symfony-bundle
pkg:composer/phil/incident-mode-bundle
Requires
- php: >=8.5
- ext-intl: *
- ext-mbstring: *
- doctrine/dbal: ^4.5
- phil/incident-mode: ^0.2@dev
- psr/clock: ^1.0
- symfony/config: ^8.2
- symfony/dependency-injection: ^8.2
- symfony/http-foundation: ^8.2
- symfony/http-kernel: ^8.2
- symfony/routing: ^8.2
- symfony/security-core: ^8.2
- symfony/security-csrf: ^8.2
- symfony/translation: ^8.2
- symfony/translation-contracts: ^3.6
- symfony/ux-twig-component: ^3.7
- twig/intl-extra: ^3.30
- twig/twig: ^3.21
Requires (Dev)
- doctrine/doctrine-bundle: ^3.3
- doctrine/orm: ^3.7
- phil/audit-bundle: ^0.1@dev
- phil/privacy-bundle: ^0.1@dev
- phil/ux-kit: >=0.5.0-alpha <1.0
- phpunit/phpunit: ^13.4
- psr/log: ^3.0
- symfony/browser-kit: ^8.2
- symfony/clock: ^8.2
- symfony/console: ^8.2
- symfony/css-selector: ^8.2
- symfony/dom-crawler: ^8.2
- symfony/event-dispatcher: ^8.2
- symfony/form: ^8.2
- symfony/framework-bundle: ^8.2
- symfony/messenger: ^8.2
- symfony/options-resolver: ^8.2
- symfony/scheduler: ^8.2
- symfony/twig-bundle: ^8.2
- symfony/ux-toolkit: ^3.7.1
- twig/html-extra: ^3.24
Suggests
- doctrine/orm: To add the table of the incidents to the schema the ORM generates, so that doctrine:migrations:diff writes its migration
- phil/audit-bundle: To write every start, extension and lifting to its tamper-evident trail
- phil/privacy-bundle: For the incidents a member started or lifted in the export and the erasure of their data
- phil/ux-kit: For the recipes the pages draw — Alert, Badge, Button, Field, Input, NativeSelect, Table, Textarea —, through the Symfony UX Toolkit
- phil/ux-kit-shadcn: For the Tailwind look, with the same recipes of the Shadcn kit of the Symfony UX Toolkit
- symfony/console: For the commands that start, extend, lift and list the incidents
- symfony/form: For the option suspended_during of the forms
- symfony/messenger: To lift each incident at its end by a delayed message
- symfony/scheduler: For the recurring sweep that lifts the incidents whose message a transport lost
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-19 00:46:27 UTC
README
The incident mode of phil/incident-mode in a Symfony application: suspend sign-ups, invitations, new messages or everything but reading for a duration that is always set, from an administration page or the console, and say so honestly to every visitor until it ends.
phil/incident-mode-bundle wires the library phil/incident-mode into Symfony. Its table lives on the DBAL connection
the application chooses, and the schema listener of the library adds it to the schema Doctrine generates. The presets
come from the configuration: the five built-in ones, the application's own, some replaced or left out. An incident is
started, extended within its preset and lifted from an administration page — protected by a role, every form posted
with a CSRF token, built from the recipes of the PHIL UX kit or of the Shadcn kit — or from four console commands, in
the name of an actor known by a stable identifier, never an e-mail address.
While an incident is in force, the checkpoints refuse what it suspends: a controller that carries
#[SuspendedDuring('signups')], a route whose defaults name a restriction, a code path that calls
Checkpoint::guard(), a form with the option suspended_during. A refusal is a page that says what is suspended and
until when, in the visitor's language and the configured time zone, with the status 503 and a Retry-After header. A
banner and a public status page say the same. Established members are spared from the restrictions the configuration
lists, through the library's port EstablishedMembers, which the application points at its own trust levels.
Each incident is lifted at its end by the library's delayed Messenger message, and a recurring sweep of Symfony
Scheduler records the end of any incident whose message a transport lost. The events of the library go through
Symfony's event dispatcher; with phil/audit-bundle registered, every start, extension and lifting is written to its
trail, and with phil/privacy-bundle, the incidents a member started or lifted answer their access and erasure
requests. The services keep nothing between requests.
Status
| Part | State |
|---|---|
| The table on a configurable connection, the schema listener, the presets of the configuration | Implemented and tested on SQLite, MySQL and PostgreSQL |
phil:incident:start, phil:incident:extend, phil:incident:lift, phil:incident:list |
Implemented and tested |
| The administration page: start from a preset, extend within it, lift, the journal a page at a time | Implemented and tested with the PHIL UX kit and the Shadcn kit |
| The lifting by the delayed Messenger message and the recurring sweep of Symfony Scheduler | Implemented and tested |
| The refusal page, the status page, the notice fragment, the banner, the Twig functions | Implemented and tested in English and French |
#[SuspendedDuring], the route default _suspended_during, Checkpoint, the option suspended_during of the forms |
Implemented and tested |
Established members spared through EstablishedMembers, visitors never |
Implemented and tested |
| The audit through phil/audit-bundle, the export and erasure through phil/privacy-bundle | Implemented and tested |
| A table name of the application's choosing | Not available: the library names its table phil_incident_activation |
Documentation
| Document | What it covers |
|---|---|
| Installation | Requirements, registering the bundle, the table and its migration, the routes, the transports. |
| Configuration | Every option of phil_incident_mode, with an example. |
| Administration | The page, the role, the actor, the CSRF token, the kits, the layout and the console commands. |
| Checkpoints | The attribute, the route default, the service, the forms, the refusal page, the banner and the status page. |
| Automatic lifting | The delayed message, the recurring sweep, a cron job without Messenger. |
| Extension points | The services to replace, the events, the words and the templates. |
| Testing | The bundle's tests, the servers its integration tests read, the fuzz target and the benchmark. |
| Reference | Every class and service of the bundle. |
Quick start
composer require phil/incident-mode-bundle
# config/packages/phil_incident_mode.yaml phil_incident_mode: spare_established: [new-posts, new-comments] established_members: App\Trust\EstablishedMembers presets: suspend-listings: { label: 'Suspend new listings', restrictions: [new-listings], proposed: 4h, longest: 2d }
use Phil\IncidentModeBundle\Attribute\SuspendedDuring; #[SuspendedDuring('signups', methods: ['POST'])] public function register(Request $request): Response
{{ include('@PhilIncidentMode/_banner.html.twig') }}
Requirements
PHP 8.5 or later with ext-intl, Symfony 8.2 or later, Doctrine DBAL 4.5, Twig and the Symfony UX Twig components,
and phil/incident-mode 0.2. The console, the forms, Messenger, Scheduler, the ORM, phil/audit-bundle and
phil/privacy-bundle are used when they are installed.
Contributing
Contributions are welcome on the PHIL monorepo: read the contribution guide and the code of conduct. Report a vulnerability privately, as the security policy explains, never in a public issue.
License
MIT, © Philippe Gamache, doing business as Le Gnome Archiviste; a Parler Haut Interagir Librement project. See LICENSE.