Skip to content

Parse error: syntax error, unexpected ‘RewriterInterface’ (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in …Delegator.php on line27

Magento ver. 2.4.5-p1
PHP 8.1
Smartwave Porto theme

I am trying to install the Mageplaza Multiple Shipping Flat Rates extension via composer by running the following command:

composer require mageplaza/module-multi-flat-rates

But it gives me this Error:

Parse error: syntax error, unexpected ‘RewriterInterface’ (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /home/mymagentosite/public_html/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPluginDelegator.php on line 27

I then thought maybe I first need to install the repositories, so I tried to run this command:

composer config repositories.mageplaza composer https://repo.mageplaza.com

as per the instructions on this page here:

https://www.mageplaza.com/kb/how-to-install-magento-extension-via-composer.html

but I get the same Error:

Parse error: syntax error, unexpected ‘RewriterInterface’ (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /home/mymagentosite/public_html/vendor/laminas/laminas-dependency-plugin/src/DependencyRewriterPluginDelegator.php on line 27
1

What is causing this and how to fix it?