Skip to content

Commit 5411756

Browse files
committed
feature #43788 [DependencyInjection][FrameworkBundle][SecurityBundle][TwigBundle] Require Composer's runtime API to be present (derrabus)
This PR was merged into the 6.0 branch. Discussion ---------- [DependencyInjection][FrameworkBundle][SecurityBundle][TwigBundle] Require Composer's runtime API to be present | Q | A | ------------- | --- | Branch? | 6.0 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Recently, I was asked to help debugging a strange behavior of my client's app that surfaced only on some developer machines while others were fine. Turns out, a particular package was installed as a dev dependency (which was fine because we used it for dev tooling only at that time) and the difference between the environments was that the broken ones used Composer 2. With `ContainerBuilder::willBeAvailable()`, we have introduced logic into the very heart of the framework that exposes significantly different behavior for Composer 1 and 2. With this PR, I'd like to propose to make Composer's runtime API a requirement, essentially making the use of Composer 2 a requirement. Composer 2 has been released over a year ago and by now every developer should have been able to upgrade to version 2. I don't think that this constraint would push the ecosystem too hard. Let's make everyone's lives easier by moving on to Composer 2. Commits ------- e08b36258b Require Composer's runtime API to be present
2 parents a49fd38 + 755657b commit 5411756

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

DependencyInjection/SecurityExtension.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\DependencyInjection;
1313

14-
use Composer\InstalledVersions;
1514
use Symfony\Bridge\Twig\Extension\LogoutUrlExtension;
1615
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\AuthenticatorFactoryInterface;
1716
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\FirewallListenerFactoryInterface;
@@ -76,10 +75,6 @@ public function prepend(ContainerBuilder $container)
7675

7776
public function load(array $configs, ContainerBuilder $container)
7877
{
79-
if (!class_exists(InstalledVersions::class)) {
80-
trigger_deprecation('symfony/security-bundle', '5.4', 'Configuring Symfony without the Composer Runtime API is deprecated. Consider upgrading to Composer 2.1 or later.');
81-
}
82-
8378
if (!array_filter($configs)) {
8479
return;
8580
}
@@ -101,7 +96,7 @@ public function load(array $configs, ContainerBuilder $container)
10196

10297
$loader->load('security_authenticator.php');
10398

104-
if ($container::willBeAvailable('symfony/twig-bridge', LogoutUrlExtension::class, ['symfony/security-bundle'], true)) {
99+
if ($container::willBeAvailable('symfony/twig-bridge', LogoutUrlExtension::class, ['symfony/security-bundle'])) {
105100
$loader->load('templating_twig.php');
106101
}
107102

@@ -111,7 +106,7 @@ public function load(array $configs, ContainerBuilder $container)
111106
$loader->load('security_debug.php');
112107
}
113108

114-
if (!$container::willBeAvailable('symfony/expression-language', ExpressionLanguage::class, ['symfony/security-bundle'], true)) {
109+
if (!$container::willBeAvailable('symfony/expression-language', ExpressionLanguage::class, ['symfony/security-bundle'])) {
115110
$container->removeDefinition('security.expression_language');
116111
$container->removeDefinition('security.access.expression_voter');
117112
}
@@ -831,7 +826,7 @@ private function createExpression(ContainerBuilder $container, string $expressio
831826
return $this->expressions[$id];
832827
}
833828

834-
if (!$container::willBeAvailable('symfony/expression-language', ExpressionLanguage::class, ['symfony/security-bundle'], true)) {
829+
if (!$container::willBeAvailable('symfony/expression-language', ExpressionLanguage::class, ['symfony/security-bundle'])) {
835830
throw new \RuntimeException('Unable to use expressions as the Symfony ExpressionLanguage component is not installed. Try running "composer require symfony/expression-language".');
836831
}
837832

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
],
1818
"require": {
1919
"php": ">=8.0.2",
20+
"composer-runtime-api": ">=2.1",
2021
"ext-xml": "*",
2122
"symfony/config": "^5.4|^6.0",
2223
"symfony/dependency-injection": "^5.4|^6.0",

0 commit comments

Comments
 (0)