Skip to content

Fix the binary being broken with Symfony Console 8 - #209

Open
Amoifr wants to merge 1 commit into
symfony-tools:mainfrom
Amoifr:fix-console-add-command
Open

Fix the binary being broken with Symfony Console 8#209
Amoifr wants to merge 1 commit into
symfony-tools:mainfrom
Amoifr:fix-console-add-command

Conversation

@Amoifr

@Amoifr Amoifr commented Jul 11, 2026

Copy link
Copy Markdown

As mentioned in #208: bin/docs-builder currently dies on startup with Symfony Console 8.

$ php bin/docs-builder list
PHP Fatal error: Call to undefined method Symfony\Component\Console\Application::add() in src/Application.php:38

Application::add() was deprecated in Symfony 7.4 in favor of addCommand(), and removed in 8.0. Since composer.json allows symfony/console: ^5.2 || ^6.0 || ^7.0 || ^8.0, the call is guarded rather than swapped outright — addCommand() only exists from 7.4 on:

if (method_exists($this->application, 'addCommand')) {
    $this->application->addCommand($command);
} else {
    $this->application->add($command);
}

Why CI never caught this: the whole suite drives the command through CommandTester, so the binary — and therefore Application — is never executed. The new test runs bin/docs-builder list as a subprocess and asserts it boots and registers build:docs. It fails without the fix (exit code 255, the fatal above) and passes with it.

Verified by hand too: a full bin/docs-builder build:docs <source> <output> --symfony-version=4.0 now completes and writes the HTML files.

Full suite green: 69 tests, 156 assertions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant