-
Notifications
You must be signed in to change notification settings - Fork 28
Description
Description
While following the official documentation to extend Castor and repack it as a PHAR, I am consistently getting Symfony deprecation warnings during the PHAR build and when executing the generated PHAR.
The warnings are related to Symfony\Component\Console\Application::add() being deprecated since Symfony Console 7.4.
This is problematic because:
- the warning is displayed during
castor repack - the warning is also displayed every time the PHAR is executed
- the warning is repeated once per command, which is quite noisy for end users
Steps to reproduce
I followed exactly this documentation page:
https://castor.jolicode.com/docs/going-further/extending-castor/repack/
1. Initialize a new Composer project
composer initComposer output:
Generating autoload files
Generated autoload files
PSR-4 autoloading configured. Use "namespace Arnaud\CastorBuild;" in src/
Include the Composer autoloader with: require 'vendor/autoload.php';
2. Install Castor as a dependency
composer require jolicode/castorRelevant output:
Locking symfony/console (v7.4.1)
Locking symfony/config (v7.4.1)
Locking symfony/dependency-injection (v7.4.2)
Using version ^1.1 for jolicode/castor
3. Initialize Castor and create a simple task
vendor/bin/castorCastor creates a castor.php file with a basic Hello task.
4. Repack Castor as a PHAR
vendor/bin/castor repackWARNING [castor] User Deprecated: 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.
5. Execute the generated PHAR
./my-app.linux.pharWARNING [castor] User Deprecated: 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.
Expected behavior
-
No Symfony deprecation warnings should be displayed:
- during
castor repack - when running the generated PHAR
- during
-
Especially not in a distributed PHAR intended for end users
Actual behavior
-
Deprecation warnings are printed:
- during PHAR creation
- every time the PHAR is executed
-
The warning is repeated for each registered command
Additional context
It looks like Symfony 7.4 is being installed by Composer, while Castor itself appears to normally embed Symfony 7.3, as mentioned in this issue comment:
Because Application::add() is deprecated in Symfony Console 7.4, this leads to visible deprecation warnings when repacking and running the PHAR.
I’m not sure if:
- Castor should pin Symfony Console to
<7.4, or - Castor’s internal usage of
Application::add()should be updated toaddCommand(), or - the repack process should suppress user deprecations
But in the current state, following the official documentation leads to a PHAR that emits deprecation warnings at runtime.
Environment
- OS: Linux / WSL2
- PHP: PHP 8.4.15 (cli) (built: Nov 20 2025 17:43:25) (NTS
- Castor: ^1.1
- Symfony Console: 7.4.x (installed via Composer)
Request for guidance
It is also possible that I am misunderstanding the recommended workflow or that I am not using the repack feature correctly.
If that’s the case, I would really appreciate some guidance on the correct way to proceed in order to avoid these warnings.
Please let me know if I missed an important step, if additional configuration is required, or if this behavior is actually expected when extending and repacking Castor.
Thanks in advance for your help and for the great work on Castor 🙏