Fatal Error: Interface ‘AmpProject\Optimizer\Transformer’ not found

Error messages:

Fatal error: Interface ‘AmpProject\Optimizer\Transformer’ not found in app/code/Plumrocket/AmpComponent/Model/RemoveUnusedExtensionsTransformer.php.

or

Exception (ReflectionException): Class AmpProject\Optimizer\ErrorCollectionFactory does not exist

Issue Description

Most likely, you are experiencing this fatal error after installing the AMP extension via FTP and running bin/magento setup:di:compile.

However, running this command is not enough to complete the installation. Please make sure to follow our AMP Installation or Upgrading guide so that you don’t miss any required steps. 

In this case, you probably missed installing the AMP Toolbox, which is a crucial and required tool for the AMP extension to work properly. It helps increase Core Web Vitals score on AMP pages and convert CMS content to AMP HTML format.

Solution 1 (using Composer)

It is likely that you have not installed all the composer packages, so follow the next steps to fix it.

Step 1

Run the following command to install the required composer AMP Toolbox for PHP and Google reCAPTCHA packages:

composer require ampproject/amp-toolbox ^0.9
composer require google/recaptcha ^1.2

Step 2 (optional)

We also recommend you to install the WebP Convert composer package for the built-in support of WebP:

composer require rosell-dk/webp-convert

Solution 2 (using FTP)

If you cannot use Composer to install the missing library, you should follow the next steps:

  1. Go to the Magento root directory
  2. Download autoloader by running the following command
git clone https://github.com/plumrocket/amp-toolbox-php-loader.git lib/internal/Plumrocket/AmpProject
  1. Download AMP Toolbox for PHP:
git clone https://github.com/ampproject/amp-toolbox-php.git lib/internal/Plumrocket/AmpProject/amp-toolbox-php

Was this article helpful?