I got this error while deploying my project on AWS Elastic BeanStalk. I recently pulled my project from github, before that it deploys without issues.
On tracing the error, I found that this line @php artisan package:discover --ansi is where the issue is coming from.
Below is the error:
Generating optimized autoload files
Illuminate\Foundation\ComposerScripts::postAutoloadDump @php artisan package:discover --ansi PHP Parse error: syntax error, unexpected identifier "AnsiColorMode" in /codebuild/output/src155211532/src/vendor/symfony/console/Output/AnsiColorMode.php on line 20 Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
This works well on Docker if I delete the composer.lock file and run the command sail composer install.
Please, any help is appreciated.
If you take a look at line 20 in the file AnsiColorMode.php you will see the following code: enum AnsiColorMode. Enumerations came to PHP in 8.1 version, so I assume your PHP version in the AWS server is less than 8.1.
So you have 2 ways:
8.1.composer.json and run composer update to update vendor libraries. Before that make sure your code is compatible with that version.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With