Composer - dependencies require a PHP version ">= 8.0.0". You are running 7.4.30." |
Hi, Guys
Let's talk specifically about the Composer error in CodeIgniter ( 3 or 4 ) "Composer detected issues in your platform: Your Composer dependencies require a PHP version ">= 8.0.0". You are running 7.4.30." In the backtrace we have: \application\vendor\composer\platform_check.php Here is the error trigger! We need to block this trigger to resolve the issue How do we tell Composer to block this trigger? Easy! composer install --ignore-platform-reqs or composer update --ignore-platform-reqs But... what does this command do? Where does it record this? Again, it's easy! Two changes take place: 1) platform_check.php is deleted by Composer. So the check file no longer exists 2) In the autoload_real.php file, the line below is deleted require __DIR__ . '/platform_check.php'; You can do this manually by renaming the files (and comment line) to rename it in production environment. If you do Composer install or update, the file is created again. It's your free choice I came to this conclusion by tracing the file through the IDE with each command in Composer I think systems that use Composer behave in the same default way. My suggest https://webjump.com.br/en/composer-what-...nstall-it/ https://www.merixstudio.com/blog/what-co...t-project/ Another case... If you have two PHP versions installed, for example 7.4 and 8, Composer will first look for the config inside the composer.json file. If not defined, it will detect the version installed on your machine. At this point, problems can start if you develop in a version lower than PHP8. Errors such as Message: syntax error, unexpected '|', expecting variable (T_VARIABLE) Filename: ...application\vendor\psr\log\src\NullLogger.php Line Number: 26 This error happens because CodeIgniter(3 or 4) is running in PHP7. On line 26 we have |\Stringable. This only PHP 8 reads. How to troubleshoot the problem. Downgrade Composer packages to the version of PHP your machine is running. In the link below you learn to see your version of PHP https://phoenixnap.com/kb/check-php-version How to downgrade, or update, to the desired version? In the Application folder of CodeIgniter (App CI 4) we have the file composer.json Add the following lines "config": { "platform": { "php": "7.4.30" } But be careful with the syntax, there is a comma separating it Example { "config": { "platform": { "php": "7.4.30" } }, "require": { "phpoffice/phpspreadsheet": "^1.6", "mpdf/mpdf": "^8.0" } } Save the modified file Finally, run composer update When going to the production environment, make the necessary adjustments Be happy and code the easiest and most efficient way |
Welcome Guest, Not a member yet? Register Sign In |