Getting AbstractPluginManager::__construct expects a ContainerInterface at Laminas-Feed

I’m getting this error when calling to $extensions = new ExtensionPluginManager();

Seems self-explanatory?

I don’t get it, AbstractPluginManager uses Psr\Container\ContainerInterface. I followed the documentation of the webpage, I don’t know what to do :frowning:

Hello and welcome to our forums! :smiley:

With laminas-servicemanager you have a PSR container interface implementation:

$extensions = new Laminas\Feed\Reader\ExtensionPluginManager(
    new Laminas\ServiceManager\ServiceManager()
);

/** @var Laminas\Feed\Reader\Extension\Atom\Feed $atomFeed */
$atomFeed = $extensions->get(Laminas\Feed\Reader\Extension\Atom\Feed::class);

But there is also a standalone extension manager:

$extensions = new Laminas\Feed\Reader\StandaloneExtensionManager();

/** @var Laminas\Feed\Reader\Extension\Atom\Feed $atomFeed */
$atomFeed = $extensions->get('Atom\Feed');

Can you provide a link which documentation you mean?

Hi! First of all, thanks for all your help! I followed this: Basic Usage - laminas-feed - Laminas Docs

I updated my code with your example and now the error dissapeared but I got this:

Could not load extension "Youtube" using Plugin Loader. Check prefix paths are configured and extension exists.

My code is the following:

Use the correct names:

$extensionManager = Laminas\Feed\Reader\Reader::getExtensionManager();

// Add extension for entry to the extension manager
$extensionManager->add(
    'YouTube\Entry',
    Extensions\YouTube\Entry::class
);

// Register the extension so that the reader also uses it for the feeds
Laminas\Feed\Reader\Reader::registerExtension('YouTube');

The method registerExtension works for feed and entry therefore only the first part of the name is needed here.

Reference:

Thanks again! I tried a lot of alternatives and with this one that you answer i get:

“Plugin of type Extensions\YouTube\Entry is invalid; must implement Laminas\Feed\Reader\Extension\AbstractFeed or Laminas\Feed\Reader\Extension\AbstractEntry”

The class already extends AbstractEntry. I’ve tried with extends and implements but doesn’t affect:

Make sure your class is loaded, use Composer for this.