From fc90d8335327ab9f3a4989e6a16349c794a500a2 Mon Sep 17 00:00:00 2001 From: W0rma Date: Tue, 1 Oct 2024 08:07:25 +0200 Subject: [PATCH 01/14] [Scheduler] Add example about how to pass arguments to a Symfony command --- scheduler.rst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scheduler.rst b/scheduler.rst index 160ba26e0cb..a77d2239259 100644 --- a/scheduler.rst +++ b/scheduler.rst @@ -473,6 +473,20 @@ The attribute takes more parameters to customize the trigger:: // defines the timezone to use #[AsCronTask('0 0 * * *', timezone: 'Africa/Malabo')] +Arguments/options for Symfony commands are passed as plain string:: + + use Symfony\Component\Console\Command\Command; + + #[AsCronTask('0 0 * * *', arguments: 'arg --my-option')] + class MyCommand extends Command + { + protected function configure(): void + { + $this->addArgument('my-arg'); + $this->addOption('my-option'); + } + } + .. versionadded:: 6.4 The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsCronTask` attribute @@ -522,6 +536,20 @@ The ``#[AsPeriodicTask]`` attribute takes many parameters to customize the trigg } } +Arguments/options for Symfony commands are passed as plain string:: + + use Symfony\Component\Console\Command\Command; + + #[AsPeriodicTask(frequency: '1 day', arguments: 'arg --my-option')] + class MyCommand extends Command + { + protected function configure(): void + { + $this->addArgument('my-arg'); + $this->addOption('my-option'); + } + } + .. versionadded:: 6.4 The :class:`Symfony\\Component\\Scheduler\\Attribute\\AsPeriodicTask` attribute From 3dca32e1cf1838b812d61e04baeade9b2e5b1716 Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Fri, 17 Jan 2025 10:45:36 +0100 Subject: [PATCH 02/14] [Mercure] Adding hint for multiple topics Page: https://symfony.com/doc/6.4/mercure.html#subscribing Closes https://github.com/symfony/symfony-docs/issues/20574 Closes https://github.com/symfony/mercure-bundle/issues/71 Closes https://github.com/symfony/mercure-bundle/issues/82 Info is taken from https://github.com/symfony/symfony-docs/issues/20574#issuecomment-2597102678 --- mercure.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mercure.rst b/mercure.rst index f37c40ddee7..698de373a17 100644 --- a/mercure.rst +++ b/mercure.rst @@ -309,6 +309,11 @@ as patterns: } +However, on the client side (i.e. in JavaScript's ``EventSource``), there is no built-in way +to see which topic a certain message is coming from. So if this (or any other meta information) +is important to you, you need to include it in the message's data (e.g. by adding a key to the +JSON, or a `data-*` attribute to the HTML). + .. tip:: Test if a URI Template matches a URL using `the online debugger`_ From b9e2005cc3e1d1fde6d2f97382a6d37bac14bc8a Mon Sep 17 00:00:00 2001 From: Thomas Landauer Date: Sat, 18 Jan 2025 13:19:11 +0100 Subject: [PATCH 03/14] [Console] Adding associative array Page: https://symfony.com/doc/6.4/components/console/helpers/questionhelper.html#let-the-user-choose-from-a-list-of-answers --- components/console/helpers/questionhelper.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index 2670ec3084a..e8c2d40a470 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -128,7 +128,7 @@ but ``red`` could be set instead (could be more explicit):: $question = new ChoiceQuestion( 'Please select your favorite color (defaults to red)', // choices can also be PHP objects that implement __toString() method - ['red', 'blue', 'yellow'], + ['red', 'blue', 'yellow'], // pass an associative array to display custom indices: [3 => 'red', 7 => 'blue'] 0 ); $question->setErrorMessage('Color %s is invalid.'); From e5e62c487425a84bafe41b424ddf51601bae9d21 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 21 Jan 2025 09:12:14 +0100 Subject: [PATCH 04/14] Minor tweaks --- mercure.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mercure.rst b/mercure.rst index 698de373a17..42ad9798d3c 100644 --- a/mercure.rst +++ b/mercure.rst @@ -309,10 +309,11 @@ as patterns: } -However, on the client side (i.e. in JavaScript's ``EventSource``), there is no built-in way -to see which topic a certain message is coming from. So if this (or any other meta information) -is important to you, you need to include it in the message's data (e.g. by adding a key to the -JSON, or a `data-*` attribute to the HTML). +However, on the client side (i.e. in JavaScript's ``EventSource``), there is no +built-in way to know which topic a certain message originates from. If this (or +any other meta information) is important to you, you need to include it in the +message's data (e.g. by adding a key to the JSON, or a ``data-*`` attribute to +the HTML). .. tip:: From 53b7a44f7afabbe9b9502cb48ff1971d776689f9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 21 Jan 2025 09:52:45 +0100 Subject: [PATCH 05/14] Reword --- components/console/helpers/questionhelper.rst | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index e8c2d40a470..3dc97d5c0d3 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -128,7 +128,7 @@ but ``red`` could be set instead (could be more explicit):: $question = new ChoiceQuestion( 'Please select your favorite color (defaults to red)', // choices can also be PHP objects that implement __toString() method - ['red', 'blue', 'yellow'], // pass an associative array to display custom indices: [3 => 'red', 7 => 'blue'] + ['red', 'blue', 'yellow'], 0 ); $question->setErrorMessage('Color %s is invalid.'); @@ -145,6 +145,28 @@ The option which should be selected by default is provided with the third argument of the constructor. The default is ``null``, which means that no option is the default one. +Choice questions display both the choice value and a numeric index, which starts +from 0 by default. The user can type either the numeric index or the choice value +to make a selection: + +.. code-block:: terminal + + Please select your favorite color (defaults to red): + [0] red + [1] blue + [2] yellow + > + +.. tip:: + + To use custom indices, pass an array with custom numeric keys as the choice + values:: + + new ChoiceQuestion('Select a room:', [ + 102 => 'Room Foo', + 213 => 'Room Bar', + ]); + If the user enters an invalid string, an error message is shown and the user is asked to provide the answer another time, until they enter a valid string or reach the maximum number of attempts. The default value for the maximum number From 35df8ae759bf455557cb9f9b530c02231cc8ced1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 22 Jan 2025 09:23:07 +0100 Subject: [PATCH 06/14] Reword --- scheduler.rst | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/scheduler.rst b/scheduler.rst index 6cebb354137..5bac82d98ae 100644 --- a/scheduler.rst +++ b/scheduler.rst @@ -473,19 +473,10 @@ The attribute takes more parameters to customize the trigger:: // defines the timezone to use #[AsCronTask('0 0 * * *', timezone: 'Africa/Malabo')] -Arguments/options for Symfony commands are passed as plain string:: - - use Symfony\Component\Console\Command\Command; - - #[AsCronTask('0 0 * * *', arguments: 'arg --my-option')] + // when applying this attribute to a Symfony console command, you can pass + // arguments and options to the command using the 'arguments' option: + #[AsCronTask('0 0 * * *', arguments: 'some_argument --some-option --another-option=some_value')] class MyCommand extends Command - { - protected function configure(): void - { - $this->addArgument('my-arg'); - $this->addOption('my-option'); - } - } .. versionadded:: 6.4 @@ -536,19 +527,10 @@ The ``#[AsPeriodicTask]`` attribute takes many parameters to customize the trigg } } -Arguments/options for Symfony commands are passed as plain string:: - - use Symfony\Component\Console\Command\Command; - - #[AsPeriodicTask(frequency: '1 day', arguments: 'arg --my-option')] + // when applying this attribute to a Symfony console command, you can pass + // arguments and options to the command using the 'arguments' option: + #[AsPeriodicTask(frequency: '1 day', arguments: 'some_argument --some-option --another-option=some_value')] class MyCommand extends Command - { - protected function configure(): void - { - $this->addArgument('my-arg'); - $this->addOption('my-option'); - } - } .. versionadded:: 6.4 From 833e338690d7250e983a89198d9e8e393f41d516 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Wed, 22 Jan 2025 09:25:10 +0100 Subject: [PATCH 07/14] Remove myself from active core members --- contributing/code/core_team.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contributing/code/core_team.rst b/contributing/code/core_team.rst index 5f41ec0b4cf..1b1703e4f93 100644 --- a/contributing/code/core_team.rst +++ b/contributing/code/core_team.rst @@ -70,7 +70,6 @@ Active Core Members * **Alexander M. Turek** (`derrabus`_); * **Jérémy Derussé** (`jderusse`_); * **Oskar Stark** (`OskarStark`_); - * **Thomas Calvet** (`fancyweb`_); * **Mathieu Santostefano** (`welcomattic`_); * **Kevin Bond** (`kbond`_); * **Jérôme Tamarelle** (`gromnan`_). @@ -114,7 +113,8 @@ Symfony contributions: * **Tobias Schultze** (`Tobion`_); * **Maxime Steinhausser** (`ogizanagi`_); * **Titouan Galopin** (`tgalopin`_); -* **Michael Cullum** (`michaelcullum`_). +* **Michael Cullum** (`michaelcullum`_); +* **Thomas Calvet** (`fancyweb`_). Core Membership Application ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From b9c7139364f16c941099891df800930c1dfd724f Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Sat, 18 Jan 2025 02:05:12 -0300 Subject: [PATCH 08/14] [Logging] Add references to the `ConsoleLogger` --- logging.rst | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/logging.rst b/logging.rst index c66312f88f9..0aabf9c7c5f 100644 --- a/logging.rst +++ b/logging.rst @@ -1,8 +1,10 @@ Logging ======= -Symfony comes with a minimalist `PSR-3`_ logger: :class:`Symfony\\Component\\HttpKernel\\Log\\Logger`. -In conformance with `the twelve-factor app methodology`_, it sends messages starting from the +Symfony comes with two minimalist `PSR-3`_ loggers: :class:`Symfony\\Component\\HttpKernel\\Log\\Logger` +for the HTTP context and :class:`Symfony\\Component\\Console\\Logger\\ConsoleLogger` for the +CLI context. +In conformance with `the twelve-factor app methodology`_, they send messages starting from the ``WARNING`` level to `stderr`_. The minimal log level can be changed by setting the ``SHELL_VERBOSITY`` environment variable: @@ -17,13 +19,18 @@ The minimal log level can be changed by setting the ``SHELL_VERBOSITY`` environm ========================= ================= The minimum log level, the default output and the log format can also be changed by -passing the appropriate arguments to the constructor of :class:`Symfony\\Component\\HttpKernel\\Log\\Logger`. -To do so, :ref:`override the "logger" service definition `. +passing the appropriate arguments to the constructor of :class:`Symfony\\Component\\HttpKernel\\Log\\Logger` +and :class:`Symfony\\Component\\Console\\Logger\\ConsoleLogger`. + +The :class:`Symfony\\Component\\HttpKernel\\Log\\Logger` class is available through the ``logger`` service. +To pass your configuration, you can :ref:`override the "logger" service definition `. + +For more information about ``ConsoleLogger``, see :doc:`/components/console/logger`. Logging a Message ----------------- -To log a message, inject the default logger in your controller or service:: +To log a message using the ``logger`` service, inject the default logger in your controller or service:: use Psr\Log\LoggerInterface; // ... @@ -55,7 +62,7 @@ Adding placeholders to log messages is recommended because: * It's better for security, because escaping can then be done by the implementation in a context-aware fashion. -The ``logger`` service has different methods for different logging levels/priorities. +The logger implementations has different methods for different logging levels/priorities. See `LoggerInterface`_ for a list of all of the methods on the logger. Monolog From fa4563353e498b9a6dc3ce20c3043f720fe1493e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 22 Jan 2025 10:29:43 +0100 Subject: [PATCH 09/14] Minor tweaks --- logging.rst | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/logging.rst b/logging.rst index 0aabf9c7c5f..0ad36031dd5 100644 --- a/logging.rst +++ b/logging.rst @@ -3,9 +3,8 @@ Logging Symfony comes with two minimalist `PSR-3`_ loggers: :class:`Symfony\\Component\\HttpKernel\\Log\\Logger` for the HTTP context and :class:`Symfony\\Component\\Console\\Logger\\ConsoleLogger` for the -CLI context. -In conformance with `the twelve-factor app methodology`_, they send messages starting from the -``WARNING`` level to `stderr`_. +CLI context. In conformance with `the twelve-factor app methodology`_, they send messages +starting from the ``WARNING`` level to `stderr`_. The minimal log level can be changed by setting the ``SHELL_VERBOSITY`` environment variable: @@ -30,7 +29,7 @@ For more information about ``ConsoleLogger``, see :doc:`/components/console/logg Logging a Message ----------------- -To log a message using the ``logger`` service, inject the default logger in your controller or service:: +To log a message, inject the default logger in your controller or service:: use Psr\Log\LoggerInterface; // ... @@ -62,7 +61,7 @@ Adding placeholders to log messages is recommended because: * It's better for security, because escaping can then be done by the implementation in a context-aware fashion. -The logger implementations has different methods for different logging levels/priorities. +The ``logger`` service has different methods for different logging levels/priorities. See `LoggerInterface`_ for a list of all of the methods on the logger. Monolog From 75a197b4f99ac3e80357d884f477067888f79df3 Mon Sep 17 00:00:00 2001 From: Sarim Khan Date: Thu, 23 Jan 2025 00:24:18 +0600 Subject: [PATCH 10/14] Caddy configuration don't allow sub-directory php files to execute. Fixes #20593 --- setup/web_server_configuration.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup/web_server_configuration.rst b/setup/web_server_configuration.rst index acd76c342b9..e5e06a89feb 100644 --- a/setup/web_server_configuration.rst +++ b/setup/web_server_configuration.rst @@ -207,6 +207,9 @@ When using Caddy on the server, you can use a configuration like this: # otherwise, use PHP-FPM (replace "unix//var/..." with "127.0.0.1:9000" when using TCP) php_fastcgi unix//var/run/php/php8.3-fpm.sock { + # only fallback to root index.php aka front controller. + try_files {path} index.php + # optionally set the value of the environment variables used in the application # env APP_ENV "prod" # env APP_SECRET "" From 698c0e74c09b10fd032e26133546b31f9e0aab9b Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Wed, 22 Jan 2025 18:51:24 -0300 Subject: [PATCH 11/14] Bump lowest maintained version to 6.4 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ed323a8ee83..5c063058c02 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,8 @@ We love contributors! For more information on how you can contribute, please rea the [Symfony Docs Contributing Guide](https://symfony.com/doc/current/contributing/documentation/overview.html). > [!IMPORTANT] -> Use `5.4` branch as the base of your pull requests, unless you are documenting a -> feature that was introduced *after* Symfony 5.4 (e.g. in Symfony 7.1). +> Use `6.4` branch as the base of your pull requests, unless you are documenting a +> feature that was introduced *after* Symfony 6.4 (e.g. in Symfony 7.2). Build Documentation Locally --------------------------- From aabca8e1d3d8b604ecd05a4e6532774369d02a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 22 Jan 2025 15:57:04 +0100 Subject: [PATCH 12/14] [RateLimiter] [Rate Limiter] Mention the Caddy/FrankenPHP rate limit module --- rate_limiter.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 970d71c8784..a53f679f1c8 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -16,8 +16,9 @@ time, but you can use them for your own features too. By definition, the Symfony rate limiters require Symfony to be booted in a PHP process. This makes them not useful to protect against `DoS attacks`_. Such protections must consume the least resources possible. Consider - using `Apache mod_ratelimit`_, `NGINX rate limiting`_ or proxies (like - AWS or Cloudflare) to prevent your server from being overwhelmed. + using `Apache mod_ratelimit`_, `NGINX rate limiting`_, + `Caddy HTTP rate limit module`_ (also supported by FrankenPHP) + or proxies (like AWS or Cloudflare) to prevent your server from being overwhelmed. .. _rate-limiter-policies: @@ -543,6 +544,7 @@ you can use a specific :ref:`named lock ` via the .. _`DoS attacks`: https://cheatsheetseries.owasp.org/cheatsheets/Denial_of_Service_Cheat_Sheet.html .. _`Apache mod_ratelimit`: https://httpd.apache.org/docs/current/mod/mod_ratelimit.html .. _`NGINX rate limiting`: https://www.nginx.com/blog/rate-limiting-nginx/ +.. _`Caddy HTTP rate limit module`: https://github.com/mholt/caddy-ratelimit .. _`token bucket algorithm`: https://en.wikipedia.org/wiki/Token_bucket .. _`PHP date relative formats`: https://www.php.net/manual/en/datetime.formats.php#datetime.formats.relative .. _`Race conditions`: https://en.wikipedia.org/wiki/Race_condition From cc4f5c511945a46b5c152b7f236cbcbe3ece2356 Mon Sep 17 00:00:00 2001 From: Nassim LOUNADI <39556046+nassimlnd@users.noreply.github.com> Date: Wed, 15 Jan 2025 16:29:46 +0100 Subject: [PATCH 13/14] Update translations --- translation.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/translation.rst b/translation.rst index ed44b6d4912..98b90949b6a 100644 --- a/translation.rst +++ b/translation.rst @@ -145,7 +145,7 @@ different formats: .. code-block:: yaml # translations/messages.fr.yaml - Symfony is great: J'aime Symfony + Symfony is great: Symfony est génial .. code-block:: xml @@ -156,7 +156,7 @@ different formats: Symfony is great - J'aime Symfony + Symfony est génial @@ -166,14 +166,14 @@ different formats: // translations/messages.fr.php return [ - 'Symfony is great' => "J'aime Symfony", + 'Symfony is great' => 'Symfony est génial', ]; You can find more information on where these files :ref:`should be located `. Now, if the language of the user's locale is French (e.g. ``fr_FR`` or ``fr_BE``), -the message will be translated into ``J'aime Symfony``. You can also translate +the message will be translated into ``Symfony est génial``. You can also translate the message inside your :ref:`templates `. .. _translation-real-vs-keyword-messages: @@ -1219,7 +1219,7 @@ for the ``fr`` locale: Symfony is great - J'aime Symfony + Symfony est génial @@ -1228,13 +1228,13 @@ for the ``fr`` locale: .. code-block:: yaml # translations/messages.fr.yaml - Symfony is great: J'aime Symfony + Symfony is great: Symfony est génial .. code-block:: php // translations/messages.fr.php return [ - 'Symfony is great' => 'J\'aime Symfony', + 'Symfony is great' => 'Symfony est génial', ]; and for the ``en`` locale: @@ -1277,7 +1277,7 @@ To inspect all messages in the ``fr`` locale for the application, run: --------- ------------------ ---------------------- ------------------------------- State Id Message Preview (fr) Fallback Message Preview (en) --------- ------------------ ---------------------- ------------------------------- - unused Symfony is great J'aime Symfony Symfony is great + unused Symfony is great Symfony est génial Symfony is great --------- ------------------ ---------------------- ------------------------------- It shows you a table with the result when translating the message in the ``fr`` @@ -1297,7 +1297,7 @@ output: --------- ------------------ ---------------------- ------------------------------- State Id Message Preview (fr) Fallback Message Preview (en) --------- ------------------ ---------------------- ------------------------------- - Symfony is great J'aime Symfony Symfony is great + Symfony is great Symfony est génial Symfony is great --------- ------------------ ---------------------- ------------------------------- The state is empty which means the message is translated in the ``fr`` locale From 922fa713756b22cc71beab7b9571157275ddc46b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 28 Jan 2025 08:57:41 +0100 Subject: [PATCH 14/14] fix typo --- setup/web_server_configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup/web_server_configuration.rst b/setup/web_server_configuration.rst index e5e06a89feb..58935bf5352 100644 --- a/setup/web_server_configuration.rst +++ b/setup/web_server_configuration.rst @@ -207,7 +207,7 @@ When using Caddy on the server, you can use a configuration like this: # otherwise, use PHP-FPM (replace "unix//var/..." with "127.0.0.1:9000" when using TCP) php_fastcgi unix//var/run/php/php8.3-fpm.sock { - # only fallback to root index.php aka front controller. + # only fall back to root index.php aka front controller. try_files {path} index.php # optionally set the value of the environment variables used in the application