Home / Symfony / New in Symfony 7.4: Misc Features (Part 3)

New in Symfony 7.4: Misc Features (Part 3)

Structured MIME Suffix Support


Florent Morselli
Contributed by
Florent Morselli
in
#61267

Although common MIME types are simple (text/css, application/javascript),
sometimes you have to deal with more complex MIME types that include subtypes.
These are defined in RFC 2045 and look like application/hal+xml or
application/device-config+tlv.

In Symfony 7.4, we improved the getFormat() method of the Request class
so you get more accurate formats when providing a complex MIME type with
subtypes. This feature is available through a new boolean parameter (false
by default to keep backward compatibility). Set it to true to try to extract
the format from the subtype when no match is found using the full MIME type:

$request->getFormat('application/device-config+tlv', true);
// returns 'tlv'

MicrosoftGraph Mailer Integration


Bob van de Vijver
Contributed by
Bob van de Vijver
in
#61290

Symfony provides built-in integration with 18 mailer services such as Azure,
Amazon SES, Mailgun, and Mandrill. In Symfony 7.4, we are adding a new
integration with the Microsoft Graph API Email endpoint.

Untranslated Messages


Vincent Langlet
Contributed by
Vincent Langlet
in
#60935

In many Symfony applications, it is common to have code like this:

if ($message instanceof Translatable) {
    $message->trans($translator);
} else {
    $translator->trans($message, domain: 'SomeBundle');
}

This means that Translatable objects are always translated, as they usually
should be. However, sometimes you might have special messages that should remain
invariant or have already been translated outside Symfony. In those cases, you
can use the new StaticMessage class, which implements TranslatableInterface
but does not perform any translation:

$message = new TranslatableMessage('Symfony is great');
$message->trans($translator, 'es');
// 'Symfony es genial'

use SymfonyComponentTranslationStaticMessage;

$message = new StaticMessage('Symfony is great');
$message->trans($translator, 'es');
// 'Symfony is great'

New Email Assert


Santiago San Martin
Contributed by
Santiago San Martin
in
#60740

Symfony provides tens of custom PHPUnit assertions such as
assertResponseHasHeader() and assertPageTitleContains() to simplify
common tests in Symfony web applications.

In Symfony 7.4, we added a new assertion called assertEmailAddressNotContains(),
which complements the existing assertEmailAddressContains(). It checks that
the given email address is not included in a specific header of an email message:

$this->assertEmailAddressNotContains($email, 'To', '[email protected]');

Profiling EventSource Requests


Valtteri R
Contributed by
Valtteri R
in
#61311

The Symfony profiler is an essential tool that lets you inspect and debug any
aspect of the current request(s). In Symfony 7.4, we improved the Ajax panel so
it not only captures and profiles Ajax requests but also requests triggered by
JavaScript’s EventSource (Server-Sent Events).

You will now see these requests as event-stream entries in the web debug toolbar:

Symfony 7.4 profiler showing EventSource requests in the Ajax panel

This is the last blog post in the New in Symfony 7.4 series. We hope you
enjoyed reading it and that you upgrade your Symfony applications soon. Meanwhile,
work on Symfony 8.1 has already begun in preparation for its release in May 2026.


Sponsor the Symfony project.
Tagged:

Leave a Reply

Your email address will not be published. Required fields are marked *