From: Raphaƫl Gertz Date: Wed, 2 Dec 2026 14:10:11 +0000 (+0100) Subject: Recipe symfony/framework-bundle update X-Git-Url: https://git.rapsys.eu/.gitweb.cgi/airlibre/commitdiff_plain/70fa07773e2781ca6b812e73d8340217a2a62c6a?ds=inline Recipe symfony/framework-bundle update --- diff --git a/.env.dev b/.env.dev index e69de29..01df25d 100644 --- a/.env.dev +++ b/.env.dev @@ -0,0 +1,3 @@ +###> symfony/framework-bundle ### +APP_SECRET=1131ca55e74458a10c11f6fd890a9c9c +###< symfony/framework-bundle ### diff --git a/.gitignore b/.gitignore index 4828442..dc675cc 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,9 @@ /.env.local /.env.local.php /.env.*.local -/config/secrets/ +/config/secrets/*/*.decrypt.private.php +!/config/secrets/dev/dev.decrypt.private.php +!/config/secrets/test/test.decrypt.private.php /public/bundles/ /var/ /vendor/ diff --git a/.symfony.local.yaml b/.symfony.local.yaml new file mode 100644 index 0000000..0d7de81 --- /dev/null +++ b/.symfony.local.yaml @@ -0,0 +1,12 @@ +# This configuration file is used by the Symfony CLI tool. +# See https://symfony.com/doc/current/setup/symfony_cli.html for more information. + +http: + use_gzip: true + +# Processes that automatically run with the server (https://symfony.com/doc/current/setup/symfony_cli.html#configuring-workers) +workers: + # Consume async messages, and restart the worker when the code changes + #messenger_consume_async: + # cmd: ['symfony', 'console', 'messenger:consume', 'async'] + # watch: ['config', 'src', 'templates', 'vendor/composer/installed.json'] diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..cf970e9 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,125 @@ +# AGENTS.md + +This is a Symfony application. `composer.json` gives the versions of Symfony and +PHP. `symfony.lock` lists the recipes that ran. Check both before you assume +that a package is installed. + +## Installing packages + +Before writing infrastructure code or adding a third-party library, check +whether a Symfony component does the job: Lock, Cache, HttpClient, Mailer, +Messenger, Scheduler, RateLimiter, Workflow... Usually there is one, and +`composer require` installs it. + +## Configuration + +- Since Symfony 8.2, each component is configured at its own root key: + `messenger:`, `cache:`, `mailer:`, `validation:`... not under `framework:` as + in older versions. +- `config/reference.php` describes every option of the installed bundles, and + `config/schema.json` is their JSON schema, which editors use and `lint:yaml` + checks when `opis/json-schema` is installed. Both are regenerated when the + container is rebuilt in debug mode. Read them instead of guessing an option. +- Prefer attributes to configuration files: `#[Route]`, `#[IsGranted]`, + `#[AsCommand]`, `#[AsEventListener]`, `#[AsMessageHandler]`, `#[Autowire]`, + `#[Target]`... Services are autowired and autoconfigured, so a service + definition in YAML is the last resort. +- Map request data with `#[MapRequestPayload]` and `#[MapQueryString]` on the + arguments of an action. These attributes deserialize and validate the data, + unlike `json_decode()`. +- `.env` is committed and contains default values only. Secrets go in + `.env.local`, which is ignored by git, or in the vault + (`bin/console secrets:set`). + +## Running the app + +- If `compose.yaml` runs services (database, mailer...), run commands through + the Symfony CLI: `symfony console ...`, `symfony php bin/phpunit`. The CLI + exposes the env vars of the running containers, and `bin/console` alone + doesn't see them. `symfony serve -d` starts a web server. +- There's no need to clear the cache in dev: the kernel rebuilds what changed. +- When something fails, read `var/log/dev.log` and the profiler (`/_profiler` + lists the last requests) before changing code. +- Makers (`bin/console make:*`) ask for missing arguments, and a + non-interactive shell then waits forever. Pass all the arguments, with + `--no-interaction`. + +## Tests + +`symfony/test-pack` provides PHPUnit: run `php bin/phpunit`. Extend +`WebTestCase` to test HTTP requests and `KernelTestCase` to test services. These +helpers replace a lot of setup code: + +- `$client->loginUser($user)` instead of submitting a login form; +- `MessengerAssertionsTrait`: a message sent to an async transport isn't handled + during a test. Call `consumeQueuedMessages()` and check what the handler did, + such as the email it sent, or the handler stays untested; +- `#[UseRecord]` to record HTTP exchanges once and replay them, instead of + calling real APIs; +- `ClockSensitiveTrait::mockTime()` to control the time. + +## Writing + +These rules apply to comments, commit messages, docs and anything written for +the team: + +- Write plain, factual English, because many readers aren't native speakers. + Write one idea per sentence and use verbs in their everyday sense. Repeat the + noun instead of using a pronoun that makes the reader look back. +- State facts, not how good they are. Avoid words like "robust", "seamless", + "powerful" or "simply", exclamation marks and emoji. +- Start with what changes for the reader, then explain why. Don't repeat what + the code or the diff already shows. +- Use commas, colons and parentheses, not em-dashes. +- A commit message says what changed in one line, plus a sentence or two when + the reason isn't obvious. + +## Code + +- Write a comment only for what the code can't say, such as a reason, a + reference to a spec or a non-obvious constraint. Don't narrate the code. +- Don't set an option to its default value. `config/reference.php` shows the + defaults. +- Fix a bug by writing a test that reproduces it first. +- Keep the diff to what the task needs: no unrelated renames, reformatting or + refactoring. + +## When a package gets in the way + +These rules apply to bugs, missing features, slow code paths and APIs that make +the app write boilerplate, in Symfony or in any other package: + +- Before you write a workaround, check that the problem is real. Reproduce it in + a few lines, compare the installed version with the latest release, and + search the issues and pull requests of the project. +- For a performance issue, measure it first, with the profiler or a benchmark, + and keep the numbers. +- Keep the workaround small. Link the workaround to the upstream issue or pull + request in a comment, so that it can be removed after the fix is released. +- Offer to report it upstream. Draft the issue with the reproduction or the + numbers, or a pull request with a test when the fix is clear. Ask before + posting anything, since it is published under the name of the person you + work for. +- Report security issues privately, as the security policy of the project says, + never in a public issue. For Symfony, see + https://symfony.com/doc/current/contributing/code/security.html. + +## Look it up + +Symfony's APIs change between versions, and what you remember may be outdated. +The application can tell what exists: + +- `bin/console debug:autowiring `: the services you can type-hint; +- `bin/console debug:autoconfiguration `: the attributes and interfaces + that make a class a command, a listener, a voter, a message handler...; +- `bin/console debug:config `: the configuration as resolved; +- `bin/console debug:router`, `debug:container --env-vars`, `debug:messenger`, + `debug:event-dispatcher`...; +- `bin/console lint:container`, `lint:yaml config/`, `lint:twig templates/`: to + catch errors before running; +- `vendor/symfony//CHANGELOG.md`: what each version added, deprecated + or removed. Read the sections of the recent versions before you use a + component; +- the source and the docblocks in `vendor/`; +- https://symfony.com/doc/current/, switched to the version of `composer.json` + when it differs. diff --git a/config/packages/cache.yaml b/config/packages/cache.yaml index 6899b72..9c9747d 100644 --- a/config/packages/cache.yaml +++ b/config/packages/cache.yaml @@ -1,19 +1,19 @@ -framework: - cache: - # Unique name of your app: used to compute stable namespaces for cache keys. - #prefix_seed: your_vendor_name/app_name +# yaml-language-server: $schema=../schema.json +#cache: + # Unique name of your app: used to compute stable namespaces for cache keys. + #prefix_seed: your_vendor_name/app_name - # The "app" cache stores to the filesystem by default. - # The data in this cache should persist between deploys. - # Other options include: + # The "app" cache stores to the filesystem by default. + # The data in this cache should persist between deploys. + # Other options include: - # Redis - #app: cache.adapter.redis - #default_redis_provider: redis://localhost + # Redis + #app: cache.adapter.redis + #default_redis_provider: redis://localhost - # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) - #app: cache.adapter.apcu + # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) + #app: cache.adapter.apcu - # Namespaced pools use the above "app" backend by default - #pools: - #my.dedicated.cache: null + # Namespaced pools use the above "app" backend by default + #pools: + #my.dedicated.cache: null diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml index 7e1ee1f..3fb0903 100644 --- a/config/packages/framework.yaml +++ b/config/packages/framework.yaml @@ -1,9 +1,11 @@ +# yaml-language-server: $schema=../schema.json # see https://symfony.com/doc/current/reference/configuration/framework.html framework: secret: '%env(APP_SECRET)%' # Note that the session will be started ONLY if you read or write from it. - session: true + session: + isolate_attributes: true #esi: true #fragments: true @@ -11,5 +13,3 @@ framework: when@test: framework: test: true - session: - storage_factory_id: session.storage.factory.mock_file diff --git a/config/routes/framework.yaml b/config/routes/framework.yaml index bc1feac..4aaf03c 100644 --- a/config/routes/framework.yaml +++ b/config/routes/framework.yaml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=../../vendor/symfony/routing/Loader/schema/routing.schema.json when@dev: _errors: resource: '@FrameworkBundle/Resources/config/routing/errors.php' diff --git a/src/Kernel.php b/src/Kernel.php index 779cd1f..a00950f 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -8,4 +8,12 @@ use Symfony\Component\HttpKernel\Kernel as BaseKernel; class Kernel extends BaseKernel { use MicroKernelTrait; + + /** + * @return list An array of allowed values for APP_ENV + */ + private function getAllowedEnvs(): array + { + return ['prod', 'dev', 'test']; + } }