I know there are similar questions here, but I don't see a definitive answer, nor one that works for me.

I've generated a plugin via pluginfactory.io, which has some controllers and a single service.

I can call the controllers in the CP without issue - if I just return a 'Hello world' from any of the controller methods, it works.

But when I follow the example supplied in the code comments (for the service file) inside of my controller action:


I get an exception:

Unknown Property – yii\base\UnknownPropertyException Getting unknown property: amphibian\mypluginname\MyPluginName::Importer

I have a service file called Importer in my services folder, with a class name of Importer, and a method named exampleService().

The extra section of my composer.json file lists:

"components": {
    "importer": "amphibian\\mypluginname\\services\\Importer"

What else am I missing?

  • 1
    Did you change the content of the composer.json after you installed the plugin by chance? Maybe you added the service afterwards or change the name of the service? Added this line after you ran composer update? – Robin Schambach Jul 26 '18 at 9:35
  • 3
    Based on the info provided, what @RobinSchambach says above is most likely the issue – which means that uninstalling, then re-installing the plugin will probably resolve the issue. I've been bit by this before; it's one of the reasons I'm not a fan of sticking the component config in composer.json, I feel that using the setComponents() method from the plugin's init method is by far the cleaner option. – Mats Mikkel Rummelhoff Jul 26 '18 at 12:33
  • Unfortunately, nope - I did no renaming or manual edits. This is happening via files directly downloaded from the plugin generator. – Derek Hogue Jul 26 '18 at 17:29
  • I'm out of ideas other than if you want to zip up the plugin and attach it so we can try. – Brad Bell Jul 26 '18 at 19:16
  • Had exactly the same issue with a pluginfactory generated plugin and eventually followed the setComponents instructions here: docs.craftcms.com/v3/extend/services.html#creating-a-service – Richard Frank Jan 4 '19 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.