I created a plugin for Craft 3 at pluginfactory.io.

I want to call it in my template variable

public function exampleVariable()

    // hint   AdminBar::$plugin->editLinks->exampleService()
    //$result = FacebookPageConnector::$plugin->eventsService->fetchEvents();
      $result =  FacebookPageConnector::$plugin->facebookPageConnectorEventsService->exampleService();

    //$result = FacebookPageConnector::$plugin->eventsService->fetchEvents();
    return $result;

But whatever I try to name my service, I get an exception like this:

Getting unknown property: boscho87fbconnector\facebookpageconnector\FacebookPageConnector::facebookPageConnectorEventsService

What are the correct naming conventions?

I saw an example here: https://github.com/wbrowar/craft-3-adminbar/blob/master/src/services/EditLinks.php#L48, but this did not work for me.

But when I call the predefined service from the pluginfactory: FacebookPageConnector::$plugin->facebookPageConnectorService->exampleService(), it works fine .

here images with my code

enter image description here

enter image description here

3 Answers 3


In your plugin's composer.json, add the service to extra.components to make it available on the plugin instance. You should see the predefined service already listed there.

You might need to empty the vendor folder of your craft website and reinstall your composer dependencies as Craft appears to cache this information.


It's hard to say for sure without seeing your plugin code, but my guess is you have a myplugin\serivces\FacebookPageConnectorService.php file/class defined, but not a myplugin\services\FacebookPageConnectorEventsService.php file/class defined.

  • i have a FacebookPageConnectorEventsService.php file Mar 2, 2017 at 20:11
  • What's the name of the class in that file?
    – Brad Bell
    Mar 2, 2017 at 21:47
  • Same like filname but without php Mar 2, 2017 at 22:31
  • Php shows be de class icon so this should be ok, i also tried to crate a new plugin in the pluginfactory with the same name an created the serviceclass. But this class does work neeither, sorry for my bad english 🙈 Mar 2, 2017 at 22:33
  • Is FacebookPageConnector the name of your plugin, or are you calling another plugin from within yours? Maybe it'd help if you posted a screenshot of the directory/file structure of your plugin.
    – Brad Bell
    Mar 3, 2017 at 0:34

Just came across this issue with pluginfactory.io plugin scaffold.

Turns out that the service method name was only called when starting with a lowercase. Not clear enough if it applies here but might help someone.

  • Are you saying there is something wrong with the scaffolding code on pluginfactory.io ? I'm pretty sure it's correct...? Jul 2, 2018 at 15:39
  • No - on digging further the composer.json file was specifying service names in the extra components section.
    – joomkit
    Jul 2, 2018 at 18:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.