Skip to content

Conversation

KIKOmanasijev
Copy link
Contributor

Summary

Resolves Symfony Console deprecation warnings by simply overriding the deprecated add() method to delegate to addCommand().

Problem

Since symfony/console 7.4: The "Symfony\Component\Console\Application::add()" method is deprecated and will be removed in Symfony 8.0, use "Symfony\Component\Console\Application::addCommand()" instead.

Actual error from the tests:

ErrorException: Since symfony/console 7.4: The "Symfony\Component\Console\Application::add()" method is deprecated and will be removed in Symfony 8.0, use "Symfony\Component\Console\Application::addCommand()" instead.
/Users/x/framework/vendor/symfony/deprecation-contracts/function.php:25
/Users/x/framework/vendor/symfony/console/Application.php:537
/Users/x/framework/vendor/symfony/console/Application.php:1345
/Users/x/framework/vendor/symfony/console/Application.php:619
/Users/x/framework/src/Illuminate/Console/Application.php:161
/Users/x/framework/src/Illuminate/Foundation/Console/Kernel.php:426
/Users/x/framework/src/Illuminate/Testing/PendingCommand.php:330
/Users/x/framework/src/Illuminate/Testing/PendingCommand.php:533
/Users/x/framework/tests/Testing/Console/RouteListCommandTest.php:121

Solution

  • Override the add() method in Illuminate\Console\Application
  • Delegate to addCommand() to maintain Laravel's command registration logic
  • Preserve backward compatibility while eliminating deprecation warnings

@crynobone
Copy link
Member

We will look into this when we approach the Laravel 13 release. As of now, we are targeting support for both 7.4 and 8.0 for Laravel 13 so ideally we don't want to have to add (support) deprecated method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants