This PR was merged into the 4.1 branch.
Discussion
----------
[Messenger] Add more tests around the AMQP transport
| Q | A
| ------------- | ---
| Branch? | 4.1
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | ø
| License | MIT
| Doc PR | ø
Adding more tests to the AMQP transport/factory. These should have captured the following 3 bugs: #27198, #27197, #27196.
Commits
-------
faf9382223 Add more tests around the AMQP transport
This PR was merged into the 4.1-dev branch.
Discussion
----------
[FrameworkBundle][Messenger] Remove convention-based service id generation for buses
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes (DX)
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Service ids for buses are user facing ids: ppl *will* have to deal with them when wiring their services.
Like for cache pools, we should ask ppl to declare them using full identifiers, instead of having a convention-based way to turn a name into and id (which is something nobody will be able to remember at some point.)
Commits
-------
c7a0045cbd [FrameworkBundle][Messenger] Remove convention-based service id generation for buses
This PR was merged into the 4.1-dev branch.
Discussion
----------
[Messenger] Relax messenger config and fix some bugs
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
After playing a little with the config of this component I found some bugs around.
Reproducer:
1. Install a fresh Symfony flex project with `^4.0@dev` dependencies
2. Add the `symfony/messenger` requirement
3. Add the following configuration separately:
Note that `symfony/serializer` has not been installed yet. ATM it's not required.
----------------------
Configuring my custom transport (not amqp):
```yaml
framework:
messenger:
transports:
custom: 'my_transport://localhost/msgs'
routing:
'*': custom
```
**Before** (Current behaviour):
Threw a logic exception, IMO unrelated at this point:
> Using the default encoder/decoder, Symfony Messenger requires the Serializer. Enable it or install it by running "composer require symfony/serializer-pack".
**After** (Proposal):
Pass! The Messenger's serializer config is disabled by definition because the Serializer component is not installed yet, then the related (default) encoder/decoder aliases are invalid, so the amqp transport factory service is removed altogether.
----------------------
According to the previous exception I configured my custom encoder/decoder services:
```yaml
framework:
messenger:
encoder: App\Serializer\Serializer
decoder: App\Serializer\Serializer
transports:
custom: 'my_transport://localhost/msgs'
routing:
'*': custom
```
**Before**:
The same exception has been thrown, now a bit vague according to the config:
> Using the default encoder/decoder, Symfony Messenger requires the Serializer. Enable it or install it by running "composer require symfony/serializer-pack".
**After**:
Pass! the serializer is disabled by definition but there is custom encoder/decoder services, so let's keep the amqp transport factory with their custom encoder/decoder deps.
----------------------
Just enabling the serializer option:
```yaml
framework:
messenger:
serializer: true
```
**Before**:
Pass! Unexpected, as there is no transport configuration the exception wasn't thrown and still keeps the amqp transport factory service with invalid encoder/decoder (Serializer) dependencies.
**After**:
The Serializer config & support is verified if it's enabled regardless of the transport configuration and this exception is thrown for this case:
> The default Messenger serializer cannot be enabled as the Serializer support is not enabled.
I've removed the "install" part because at this point only we're checking whether the `framework.serializer` is enabled or not, so the next step after that should be enable the Serializer support in `framework.serializer`, which already verify whether the Serializer component is installed or not. IMO "composer require symfony/serializer-pack" should be there and not here. Also because `symfony/serializer` is not a hard dependency of this component.
----------------------
By last, I disabled the serializer option manually:
```yaml
framework:
messenger:
serializer: false
transports:
custom: 'my_transport://localhost/msgs'
routing:
'*': custom
```
**Before**:
I received this DI exception:
> The service "messenger.transport.amqp.factory" has a dependency on a non-existent service "messenger.transport.serializer".
**After**:
Pass! (same behaviour that the first example)
----------------------
As I explained earlier, this PR enables or disables the Messenger's serializer config based on the current Symfony platform and whether the Serializer component is installed or not, like other config with similar behaviour.
Tests included :)
Cheers!
Commits
-------
a05e2e2c3b Relax Messenger config and fix some bugs
* 4.0:
use brace-style regex delimiters
Fixed typo RecursiveIterator -> RecursiveIteratorIterator
[Cache] fix logic for fetching tag versions on TagAwareAdapter
[FrameworkBundle] Remove dead code
[FrameworkBundle] Use the correct service id for CachePoolPruneCommand in its compiler pass
Hide short exception trace by default
[Doctrine Bridge] fix priority for doctrine event listeners
[Validator] make phpdoc of ObjectInitializerInterface interface more accurate
[Validator] fixes phpdoc reference to an interface that was removed in Symfony 3.0
* 3.4:
use brace-style regex delimiters
Fixed typo RecursiveIterator -> RecursiveIteratorIterator
[Cache] fix logic for fetching tag versions on TagAwareAdapter
[FrameworkBundle] Use the correct service id for CachePoolPruneCommand in its compiler pass
Hide short exception trace by default
[Doctrine Bridge] fix priority for doctrine event listeners
[Validator] make phpdoc of ObjectInitializerInterface interface more accurate
[Validator] fixes phpdoc reference to an interface that was removed in Symfony 3.0
This PR was squashed before being merged into the 4.1-dev branch (closes#26864).
Discussion
----------
[Messenger] Define multiple buses from the `framework.messenger.buses` configuration
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #26652
| License | MIT
| Doc PR | https://github.com/symfony/symfony-docs/issues/9617
Not everybody will benefit from having only one bus, especially with the CQRS-like usages. While keeping the extremely use of use of the single bus, this PR has the following:
- Create multiple buses from the YAML configuration
- Tag middleware only a specific buses
- Register middlewares from the YAML configuration
Even if it's visible in the PR's tests, here's how it will look like, for a completely full-customised version:
```yaml
framework:
messenger:
default_bus: commands
buses:
commands: ~
events:
middlewares:
- validation
- route_messages
- "Your\\Middleware\\Service"
- call_message_handler
```
A few things to note:
1. The YAML configuration creates `messenger.bus.[name]` services for the buses.
2. The YAML configuration for middleware just adds tags to the corresponding middlewares.
3. If the middleware definition does not exists, it creates it. (without any magic on the arguments though, if it isn't auto-wirable, well... "your problem")
4. In the PR, there is this "TolerateNoHandler" middleware that is a great example for event buses
Commits
-------
e5deb8499b [Messenger] Define multiple buses from the `framework.messenger.buses` configuration
This PR was merged into the 4.1-dev branch.
Discussion
----------
[DI][FrameworkBundle] Hide service ids that start with a dot
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | #26630
| License | MIT
| Doc PR | -
Now that services are private by default, `debug:container` should display them by default.
In fact, the public/private concept should not trigger a difference in visibility for this command.
Instead, I propose to handle service ids that start with a dot as hidden services.
PR should be ready.
(For reference, I tried using a tag instead in #26891, but that doesn't work in practice when working on the implementation.)
Commits
-------
cea051ee5e [DI][FrameworkBundle] Hide service ids that start with a dot
This PR was squashed before being merged into the 4.1-dev branch (closes#26941).
Discussion
----------
[Messenger] Allow to configure the transport
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | ish
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #26900, #26908, #26935
| License | MIT
| Doc PR | ø
We allow users to configure the encoder/decoder used by the built-in adapter(s). This also adds the support of configuring the default's encoder/decoder format and context.
Commits
-------
1a3f0bbb14 [Messenger] Allow to configure the transport
This PR was squashed before being merged into the 4.1-dev branch (closes#26909).
Discussion
----------
[Messenger][DX] Uses the adapter name instead of the service name
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | ø
| License | MIT
| Doc PR | ø
As a developer, I don't get why I would need to use the service name while I give a name to the adapters. This is basically what this PR means for me in terms of configuration:
```patch
framework:
messenger:
routing:
# We want the command below to be handled async with the "messenger.default_sender" (AMQP producer).
- 'App\Message\Command\CreateNumber': messenger.sender.amqp
+ 'App\Message\Command\CreateNumber': amqp
adapters:
amqp: "%env(AMQP_DSN)%"
```
And in terms of pulling the messages:
```patch
- bin/console messenger:consume-messages messenger.receiver.amqp
+ bin/console messenger:consume-messages amqp
```
Commits
-------
b5afb40441 [Messenger][DX] Uses the adapter name instead of the service name
This PR was squashed before being merged into the 4.1-dev branch (closes#26632).
Discussion
----------
[Messenger] Add AMQP adapter
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | ø
| License | MIT
- [x] Depends on the Messenger component #24411
- [x] Add tests once we are all happy about the structure
---
In order to give a great DX for simple needs such as sending messages through an AMQP broker such as RabbitMq, we should ship an AMQP adapter for the Messenger component within Symfony Core. It should be as simple as this proposal. We don't need to handle more specific use-cases nor brokers as other adapters such as the [enqueue adapter](https://github.com/sroze/enqueue-bridge) can also be used.
Configuring the adapter is as simple as the following configuration:
```yaml
# config/packages/messenger_adapters.yaml
framework:
messenger:
adapter: "%env(MESSENGER_DSN)%"
```
With the given `.env` for example:
```
MESSENGER_DSN=amqp://guest:guest@localhost:5672/%2f/messages
```
Keep in mind that after having configured the adapter, developers have to route their messages to the given adapter.
```yaml
# config/packages/messenger_routes.yaml
framework:
messenger:
routing:
producer).
'App\Message\Command\CreateNumber': messenger.default_sender
```
---
Additionally, multiple adapters can be created and messages routed to these ones.
```yaml
# config/packages/messenger_routes.yaml
framework:
messenger:
adapters:
commands: "amqp://guest:guest@localhost:5672/%2f/commands"
maintenance: "amqp://guest:guest@localhost:5672/%2f/maintenance"
routing:
producer).
'App\Message\Command\CreateNumber': messenger.commands_sender
'App\Message\Command\MaintenanceSpecificCommand': messenger.maintenance_sender
```
Commits
-------
798c230ad5 [Messenger] Add AMQP adapter
* 3.4: (24 commits)
moved Twig runtime to proper class
fixed deprecated messages in tests
add PHP errors options to XML schema definition
[HttpCache] Unlink tmp file on error
Added LB translation for #26327 (Errors sign for people that do not see colors)
[TwigBridge] Fix rendering of currency by MoneyType
Import InvalidArgumentException in PdoAdapter
[DI] Do not suggest writing an implementation when multiple exist
[Intl] Update ICU data to 61.1
Use 3rd person verb form in command description
[Validator] Add Japanese translation
Support phpdbg SAPI in Debug::enable()
[HttpKernel] DumpDataCollector: do not flush when a dumper is provided
[DI] Fix hardcoded cache dir for warmups
[Routing] fix tests
[Routing] Fixed the importing of files using glob patterns that match multiple resources
[Ldap] cast to string when checking empty passwords
[Validator] sync validator translation id
[WebProfilerBundle] use the router to resolve file links
no type errors with invalid submitted data types
...
* 4.0:
[Translation] Process multiple segments within a single unit.
Document the container.autowiring.strict_mode option
fix custom radios/inputs for checkbox/radio type
Another PR template tweak
[FrameworkBundle] Add missing XML config for circular_reference_handler. Add tests.
fix CS
[PropertyInfo] ReflectionExtractor: give a chance to other extractors if no properties
Clean calls to http_build_query()
[WebProfilerBundle] limit ajax request to 100 and remove the last one
Add support for URL-like DSNs for the PdoSessionHandler
removed version in @final @internal for version < 4.0
[HttpFoundation] Fix missing "throw" in JsonResponse
Improve the documentation of
Suppress warning from sapi_windows_vt100_support on stream other than STDIO
removed extra-verbose comments
Fixes#26136: Avoid emitting warning in hasParameterOption()
Added a README entry to the PR template
[HttpFoundation] Add x-zip-compressed to MimeTypeExtensionGuesser.
[DI] Add null check for removeChild
* 3.4:
[Translation] Process multiple segments within a single unit.
Document the container.autowiring.strict_mode option
fix custom radios/inputs for checkbox/radio type
Another PR template tweak
[FrameworkBundle] Add missing XML config for circular_reference_handler. Add tests.
fix CS
[PropertyInfo] ReflectionExtractor: give a chance to other extractors if no properties
Clean calls to http_build_query()
[WebProfilerBundle] limit ajax request to 100 and remove the last one
Add support for URL-like DSNs for the PdoSessionHandler
[HttpFoundation] Fix missing "throw" in JsonResponse
Improve the documentation of
Suppress warning from sapi_windows_vt100_support on stream other than STDIO
removed extra-verbose comments
Fixes#26136: Avoid emitting warning in hasParameterOption()
Added a README entry to the PR template
[HttpFoundation] Add x-zip-compressed to MimeTypeExtensionGuesser.
[DI] Add null check for removeChild
This PR was squashed before being merged into the 4.1-dev branch (closes#26108).
Discussion
----------
[Serializer] Add a MaxDepth handler
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | yes <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass? | yes
| Fixed tickets | api-platform/core#1130, api-platform/core#1528, api-platform/core#1528 <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | todo <!--highly recommended for new features-->
Sometimes, instead of just stopping the serialization process when the configured max depth is reached, it can be interesting to let the user return something (like returning the identifier of the entity to stop manually the serialization process).
This PR also makes the max depth handling more similar to circular references handling (that already has the possibility to set a handler).
Commits
-------
ed975c764b [Serializer] Add a MaxDepth handler
* 4.0:
[Bridge/Twig] fix composer.json
bug #26086 [FrameworkBundle] Fix using annotation_reader in compiler pass to inject configured cache provider
[WebProfilerBundle] Fix anchor CSS
[HttpKernel] Send new session cookie from AbstractTestSessionListener after session invalidation
[WebProfilerBundle] Tweak default route name
updated StopwatchEvent phpdoc due to the additional of optional float precision introduced in 0db8d7fb6a
Retro-fit proxy code to make it deterministic for older proxy manager implementations
[Serializer] remove unneeded php doc line
Yaml parser regression with comments and non-strings
Fixed broken tests
[TwigBridge] Apply some changes to support Bootstrap4-stable