Why did phpMyAdmin stop working after upgrading Ubuntu to 22.04?
Asked Answered
S

6

10

Just upgraded to Ubuntu 22.04 and now my phpadmin won't load. I get this following error

Parse error: syntax error, unexpected 'static' (T_STATIC) in /usr/share/php/Symfony/Component/DependencyInjection/ContainerBuilder.php on line 272

I opened up the file, and here is the specific code in that segment.

public function addResource(ResourceInterface $resource): static
{
    if (!$this->trackResources) {
        return $this;
    }

   if ($resource instanceof GlobResource && $this->inVendors($resource->getPrefix())) {
       return $this;
    }

    $this->resources[(string) $resource] = $resource;

   return $this;
}

Yesterday before the upgrade, everything was working fine. Does anybody have any suggestions?

Shellashellac answered 29/4, 2022 at 16:33 Comment(3)
What phpmyadmin and PHP itself versions do you have?Noelianoell
I'm running 7.4Shellashellac
Are you sure this problem is related to Symfony itself? Did you write any code on your own for this problem?Turin
L
12

I'm using php7.4.30 and my fix was upgrading phpMyAdmin.

Here is a simple guide:

https://devanswers.co/manually-upgrade-phpmyadmin/

Large answered 2/9, 2022 at 8:43 Comment(0)
T
7

Since version 8.0, PHP allows static as a return type for class methods. Apparently your PHP version was downgraded.

Ty answered 29/4, 2022 at 17:5 Comment(5)
so I need to uninstall php 8Shellashellac
You have to use at least PHP 8.0, or downgrade phpMyAdminTy
@GrzegorzPietrzak but he has Symfony error, not phpMyAdmin one, phpMyAdmin does not require PHP 8.0 yet, 7.4 for latest version, I believeNoelianoell
Since version 5.0 PMA uses Symfony components, including DI Container. Looking at the Packagist - it should work with PHP 7.1.3+, but apparently something is not right.Ty
solved it. Fully upgraded and added extra modules for php 8.1Shellashellac
A
3

Yes, it's a pain if you are running a PHP version prior to 8, such as 7.*. Download 5.2 here and install it.

https://www.phpmyadmin.net/downloads/

Completely purge your previous version and secure the directory where you install it (depends on your web server). That Symfony component ruined everything (line 272).

Asper answered 4/6, 2022 at 16:58 Comment(0)
C
1
  • upgrade php to 8.x
  • switch php version in apache:
cd /etc/apache2/mods-enabled/
sudo rm php7.4.conf
sudo rm php7.4.load
sudo ln -s ../mods-available/php8.0.load php8.0.load
sudo ln -s ../mods-available/php8.0.conf php8.0.conf

at the end, restart apache:

sudo /etc/init.d/apache2 restart
Chiasmus answered 26/9, 2022 at 18:36 Comment(1)
Probably not necessary but just want to add that if you're on PHP 8.1 you need to change above commands to 8.1Malvie
T
0

You have to check your phpmyadmin version Coz in php 8.* version phpmyadmin 5.* version will be required.

Thorwald answered 29/5, 2022 at 13:14 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Lanctot
R
0

Check the php version currently running php -v.

you need php 8.3. If you have it, enable the php mode 8.3 sudo a2enmod php8.3 and disable the current php mode say sudo a2dismod php7.4

then restart apache sudo systemctl restart apache2

navigate to /etc/apache2/mods-available to verify the changes. then test to access phpmyadmin

Rox answered 7/5 at 10:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.