Native HTML5 Parser
PHP 8.4 includes a native and full-featured HTML5 parser. In Symfony applications,
HTML parsers are used in the DomCrawler component and HtmlSanitizer component.
In previous Symfony versions, we relied on third-party libraries that implemented
HTML parsers in PHP code.
Starting in Symfony 7.4, Symfony uses the much faster native HTML parser from
PHP if your application runs on PHP 8.4 or higher. This is automatic, so there
is no change to make on your side.
Allow Any Protocols in Url Constraint
The Url constraint uses the protocols option to specify which protocols
are allowed when validating URLs. In Symfony 7.4 we improved this option so you
can use * to accept any protocol that follows the RFC 3986 spec (e.g.
https://, git+ssh://, file://, custom://):
// src/Entity/Author.php
namespace AppEntity;
use SymfonyComponentValidatorConstraints as Assert;
class Author
{
#[AssertUrl(protocols: ['*'])]
protected string $bioUrl;
}
Parsing Link Headers
Some APIs expose a Link HTTP header for pagination, so you must parse that
header to consume the API contents. Symfony already provides a WebLink component,
so in Symfony 7.4 we are adding an HttpHeaderParser class to parse these headers:
use SymfonyComponentWebLinkHttpHeaderParser;
$parser = new HttpHeaderParser();
// get the value of the Link header from the Request
$linkHeader = '</foo.css>; rel="prerender",</bar.otf>; rel="dns-prefetch"; pr="0.7",</baz.js>; rel="preload"; as="script"';
$links = $parser->parse($linkHeader)->getLinks();
$links[0]->getRels(); // ['prerender']
$links[1]->getAttributes(); // ['pr' => '0.7']
$links[2]->getHref(); // '/baz.js'
HTTP QUERY Method
The HTTP QUERY Method is a proposed addition to the HTTP standard. A
QUERY request is similar to a POST request but can be automatically
repeated or restarted without concern for partial state changes.
Technically, a QUERY request asks the target to “process the enclosed
content in a safe and idempotent manner and then respond with the result of
that processing”.
In Symfony 7.4, we added support for QUERY in the Request class, the
HTTP Cache feature, the web profiler, and the HttpClient component.
Resource Tags Configuration
In Symfony 7.3, we introduced resource tags so you can apply tags to classes
that are not registered as services and later get or inject those tagged
classes. In Symfony 7.4 we are improving this feature so you can configure
resource tags more easily in YAML or PHP formats:
# config/packages/services.yaml
services:
foo:
class: stdClass
resource_tags:
- { name: 'my.tag', foo: 'bar' }
- 'another.tag'
use SymfonyComponentDependencyInjectionAttributeAutoconfigureResourceTag;
#[AutoconfigureResourceTag('my.tag', ['foo' => 'bar'])]
#[AutoconfigureResourceTag('another.tag')]
class SomeClass
{
// ...
}




