Skip to content

drop support for configuring Symfony with Composer 1 #43813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getConfigTreeBuilder(): TreeBuilder
$parentPackages = (array) $parentPackage;
$parentPackages[] = 'symfony/framework-bundle';

return ContainerBuilder::willBeAvailable($package, $class, $parentPackages, true);
return ContainerBuilder::willBeAvailable($package, $class, $parentPackages);
};

$enableIfStandalone = static function (string $package, string $class) use ($willBeAvailable) {
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"require": {
"php": ">=8.0.2",
"ext-xml": "*",
"composer-runtime-api": "^2.0",
"symfony/cache": "^5.4|^6.0",
"symfony/config": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
Expand Down Expand Up @@ -72,10 +73,6 @@ public function prepend(ContainerBuilder $container)

public function load(array $configs, ContainerBuilder $container)
{
if (!class_exists(InstalledVersions::class)) {
trigger_deprecation('symfony/security-bundle', '5.4', 'Configuring Symfony without the Composer Runtime API is deprecated. Consider upgrading to Composer 2.');
}

if (!array_filter($configs)) {
return;
}
Expand All @@ -97,7 +94,7 @@ public function load(array $configs, ContainerBuilder $container)

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

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

Expand All @@ -107,7 +104,7 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('security_debug.php');
}

if (!$container::willBeAvailable('symfony/expression-language', ExpressionLanguage::class, ['symfony/security-bundle'], true)) {
if (!$container::willBeAvailable('symfony/expression-language', ExpressionLanguage::class, ['symfony/security-bundle'])) {
$container->removeDefinition('security.expression_language');
$container->removeDefinition('security.access.expression_voter');
}
Expand Down Expand Up @@ -802,7 +799,7 @@ private function createExpression(ContainerBuilder $container, string $expressio
return $this->expressions[$id];
}

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

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/SecurityBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"require": {
"php": ">=8.0.2",
"ext-xml": "*",
"composer-runtime-api": "^2.0",
"symfony/config": "^5.4|^6.0",
"symfony/dependency-injection": "^5.4|^6.0",
"symfony/event-dispatcher": "^5.4|^6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Config\Resource\FileExistenceResource;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Form\Form;
Expand All @@ -36,26 +37,22 @@ class TwigExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
if (!class_exists(InstalledVersions::class)) {
trigger_deprecation('symfony/twig-bundle', '5.4', 'Configuring Symfony without the Composer Runtime API is deprecated. Consider upgrading to Composer 2.');
}

$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('twig.php');

if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'], true)) {
if ($container::willBeAvailable('symfony/form', Form::class, ['symfony/twig-bundle'])) {
$loader->load('form.php');
}

if ($container::willBeAvailable('symfony/console', Application::class, ['symfony/twig-bundle'], true)) {
if ($container::willBeAvailable('symfony/console', Application::class, ['symfony/twig-bundle'])) {
$loader->load('console.php');
}

if ($container::willBeAvailable('symfony/mailer', Mailer::class, ['symfony/twig-bundle'], true)) {
if ($container::willBeAvailable('symfony/mailer', Mailer::class, ['symfony/twig-bundle'])) {
$loader->load('mailer.php');
}

if (!$container::willBeAvailable('symfony/translation', Translator::class, ['symfony/twig-bundle'], true)) {
if (!$container::willBeAvailable('symfony/translation', Translator::class, ['symfony/twig-bundle'])) {
$container->removeDefinition('twig.translation.extractor');
}

Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/TwigBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"require": {
"php": ">=8.0.2",
"composer-runtime-api": "^2.0",
"symfony/config": "^5.4|^6.0",
"symfony/twig-bridge": "^5.4|^6.0",
"symfony/http-foundation": "^5.4|^6.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1412,11 +1412,10 @@ public function log(CompilerPassInterface $pass, string $message)
*/
final public static function willBeAvailable(string $package, string $class, array $parentPackages): bool
{
$skipDeprecation = 3 < \func_num_args() && func_get_arg(3);
$hasRuntimeApi = class_exists(InstalledVersions::class);

if (!$hasRuntimeApi && !$skipDeprecation) {
trigger_deprecation('symfony/dependency-injection', '5.4', 'Calling "%s" when dependencies have been installed with Composer 1 is deprecated. Consider upgrading to Composer 2.', __METHOD__);
if (!$hasRuntimeApi) {
throw new LogicException('Calling "%s()" when dependencies have been installed with Composer 1 is not supported. You should upgrade to Composer 2.');
}

if (!class_exists($class) && !interface_exists($class, false) && !trait_exists($class, false)) {
Expand Down