cancel
Showing results for 
Search instead for 
Did you mean: 

storefront not working, but admin portal working fine

SOLVED

storefront not working, but admin portal working fine

I recently installed magento community edition 2.3.5 but after everything appeared to install correctly, I cannot access my storefront. The admin portal is working fine.

The error message I'm seeing is:

Exception #0 (Exception): Notice: Trying to access array offset on value of type null in /var/www/html/magento2.3/vendor/magento/framework/App/AreaList.php on line 78
<pre>#1 Magento\Framework\App\AreaList->getCodeByFrontName() called at [vendor/magento/framework/App/Http.php:111]
#2 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24]
#3 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:261]
#4 Magento\Framework\App\Bootstrap->run() called at [index.php:39]
</pre>

 when I do a search for errors in that area, I get a lot of suggestions telling me to downgrade from PHP 7.4 to PHP 7.3 - but I am already using PHP 7.3, and as the admin is working fine, I'm pretty sure that is not the issue. It seems to me that it cannot find the default area code in the database - but that's just a guess. 

Can anyone help with this?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: storefront not working, but admin portal working fine

Found the solution. PHP has a very odd way of changing versions. I had both PHP 7.4 and 7.3 installed, but in order to use 7.3 I had modified the symbolic link to the PHP.exe. This meant that although when I called "php -v" it showed that it was running 7.3, when it was running from Apache it was actually using 7.4. This because when running from Apache it will be going through the "alternatives table" to find the preferred version of PHP.

 

I don't know whoever designed this rather bizarre approach, but it definitely is a recipe for confusion and errors.

 

When using different versions of PHP, we need to use the following methodology to change the current version: 

 

sudo a2dismod php7.4
sudo a2enmod php7.3
sudo service apache2 restart
sudo update-alternatives --config php (set it to the 7.3 version)
sudo update-alternatives --config phar (set it to the 7.3 version)
sudo update-alternatives --config phar.phar (set it to the 7.3 version)
sudo service apache2 restart

 

 

View solution in original post

2 REPLIES 2

Re: storefront not working, but admin portal working fine

@patrickmag11f5 

The issue is on a live site or local?

If the issue is in live then set the PHP version again

Problem solved? Click Kudos and "Accept as Solution".
200+ Magento 2 Extensions for Enhanced Shopping Experience.

Re: storefront not working, but admin portal working fine

Found the solution. PHP has a very odd way of changing versions. I had both PHP 7.4 and 7.3 installed, but in order to use 7.3 I had modified the symbolic link to the PHP.exe. This meant that although when I called "php -v" it showed that it was running 7.3, when it was running from Apache it was actually using 7.4. This because when running from Apache it will be going through the "alternatives table" to find the preferred version of PHP.

 

I don't know whoever designed this rather bizarre approach, but it definitely is a recipe for confusion and errors.

 

When using different versions of PHP, we need to use the following methodology to change the current version: 

 

sudo a2dismod php7.4
sudo a2enmod php7.3
sudo service apache2 restart
sudo update-alternatives --config php (set it to the 7.3 version)
sudo update-alternatives --config phar (set it to the 7.3 version)
sudo update-alternatives --config phar.phar (set it to the 7.3 version)
sudo service apache2 restart