cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.3 is requiring PHP 8.1 on storefront

SOLVED

Magento 2.4.3 is requiring PHP 8.1 on storefront

I'm currently setting up a Magento 2.4.3 community edition project locally. I'm already running the PHP 7.4 version as per system requirements. However, after running the compile commands successfully, the storefront is asking for PHP 8.1. 

 

Can you please suggest any items that I need to check? 

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.4.3 is requiring PHP 8.1 on storefront

It seems your Magento storefront is detecting the PHP version incorrectly and assuming PHP 8.1 is required rather than the actual minimum of PHP 7.4 that 2.4.3 supports.

A few things to check on your local environment:

  • Confirm your actual PHP version by running `php -v` on the command line. Ensure you are using PHP 7.4+
  • Check if you have multiple PHP versions installed and if an incorrect php binary is first in path
  • Look for any custom code or PHP overrides that may be forcing the PHP version requirement check
  • Try with a fresh Magento 2.4.3 install without customizations as a baseline

Typically this PHP version detection issue is due to an environment misconfiguration rather than a problem with core Magento 2.4.3 itself.

Get your local env confirmed to be running PHP 7.4/7.3 first. Also trace through config files and custom code to spot anywhere PHP 8.1 could be explicitly getting checked/required incorrectly.

View solution in original post

3 REPLIES 3

Re: Magento 2.4.3 is requiring PHP 8.1 on storefront

It seems your Magento storefront is detecting the PHP version incorrectly and assuming PHP 8.1 is required rather than the actual minimum of PHP 7.4 that 2.4.3 supports.

A few things to check on your local environment:

  • Confirm your actual PHP version by running `php -v` on the command line. Ensure you are using PHP 7.4+
  • Check if you have multiple PHP versions installed and if an incorrect php binary is first in path
  • Look for any custom code or PHP overrides that may be forcing the PHP version requirement check
  • Try with a fresh Magento 2.4.3 install without customizations as a baseline

Typically this PHP version detection issue is due to an environment misconfiguration rather than a problem with core Magento 2.4.3 itself.

Get your local env confirmed to be running PHP 7.4/7.3 first. Also trace through config files and custom code to spot anywhere PHP 8.1 could be explicitly getting checked/required incorrectly.

Re: Magento 2.4.3 is requiring PHP 8.1 on storefront

Thank you for your help.

 

The version in the PHP binary path is wrong and it was probably due to multiple switching that I've been doing. After correcting it, my local environment is now working.

Re: Magento 2.4.3 is requiring PHP 8.1 on storefront

Hello @hazelcaquicla ,

 

If your Magento 2.4.3 installation is asking for PHP 8.1 even though you're running PHP 7.4, there might be a few things you can check to resolve this issue:

 

Magento Configuration: Double-check your Magento configuration to ensure that it's correctly pointing to the PHP 7.4 installation. You can find the PHP version specified in the .htaccess file at the root of your Magento installation, or in your web server configuration if you're using Nginx or another web server.

 

PHP Version in CLI: Run php -v in your command line interface to verify that the PHP version being used in the CLI environment is indeed 7.4. If it's not, you might need to adjust your system's PATH or PHP configuration to point to the correct PHP version.

 

Web Server Configuration: If you're using Apache or Nginx, check your virtual host configuration files to ensure that they're configured to use PHP 7.4 for your Magento installation. Make sure to restart your web server after making any changes to the

configuration files.

 

Cache Clearing: Clear any caching mechanisms that might be caching PHP configuration or other system settings. This includes opcode caches like OPcache, as well as any Magento-specific caches.

 

Magento Environment Configuration: Ensure that your Magento environment configuration is correctly set up to use PHP 7.4. You can find the configuration settings in app/etc/env.php in your Magento installation directory.

 

Magento Composer Dependencies: Check your composer.json file to ensure that it's correctly configured to use PHP 7.4-compatible dependencies. Run composer update to make sure you have the latest versions of all dependencies.

 

Magento Compiler Cache: If you're using the Magento compiler, try clearing the compiled cache by running php bin/magento setup:di:compile again.

 

Permissions and Ownership: Ensure that all files and directories in your Magento installation have the correct permissions and ownership. Improper permissions can sometimes cause issues with PHP detection.

 

Magento Cache: Clear the Magento cache by running php bin/magento cache:flush to ensure that any cached PHP configuration or system settings are refreshed.

 

Magento Root Directory: Make sure that your terminal's current directory is the root directory of your Magento installation when running any Magento CLI commands.

 

By checking these items and ensuring that your Magento installation is configured correctly to use PHP 7.4, you should be able to resolve the issue with Magento asking for PHP 8.1.

If you have any questions, feel free to contact us.