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

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

CC BY-SA 3.0
2018-02-02T17:43:43.040Z
2018-02-02T17:43:43.040Z
Oscar Barrett
<p>It's hard to say for sure without seeing your plugin code, but my guess is you have a <code>myplugin\serivces\FacebookPageConnectorService.php</code> file/class defined, but not a <code>myplugin\services\FacebookPageConnectorEventsService.php</code> file/class defined.</p>

CC BY-SA 3.0
2017-03-02T20:11:51.060Z
i have a FacebookPageConnectorEventsService.php file
Simon Müller
CC BY-SA 3.0
2017-03-02T21:47:23.757Z
What's the name of the class in that file?
Brad Bell
CC BY-SA 3.0
2017-03-02T22:31:18.923Z
Same like filname but without php
Simon Müller
CC BY-SA 3.0
2017-03-02T22:33:55.073Z
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 
Simon Müller
CC BY-SA 3.0
2017-03-03T00:34:01.017Z
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
CC BY-SA 3.0
2017-03-04T19:09:46.603Z
i added my code... 
i created a new plugin with : https://pluginfactory.io/ and as long i use the service i created there it works, if i change the class/file names it does not work anymore ... are there something i forgot about?
Simon Müller
CC BY-SA 3.0
2017-03-02T19:02:30.623Z
2017-03-02T19:02:30.623Z
Brad Bell
<p>Just came across this issue with pluginfactory.io plugin scaffold.</p>

<p>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.</p>

CC BY-SA 4.0
2018-07-02T15:39:54.177Z
Are you saying there is something wrong with the scaffolding code on pluginfactory.io ? I'm pretty sure it's correct...?
andrew.welch
CC BY-SA 4.0
2018-07-02T18:27:58.077Z
No - on digging further the composer.json file was specifying service names in the extra components section.
joomkit
CC BY-SA 4.0
2018-07-02T11:38:05.057Z
2018-07-02T11:38:05.057Z
joomkit
<p>I created a plugin for Craft 3 at <a href="https://pluginfactory.io" rel="nofollow noreferrer">pluginfactory.io</a>.</p>

<p>I want to call it in my template variable </p>

<pre><code>public function exampleVariable()
{

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

    //$result = FacebookPageConnector::$plugin-&gt;eventsService-&gt;fetchEvents();
    return $result;
}
</code></pre>

<p>But whatever I try to name my service, I get an exception like this:</p>

<blockquote>
  <p>Getting unknown property: boscho87fbconnector\facebookpageconnector\FacebookPageConnector::facebookPageConnectorEventsService</p>
</blockquote>

<p>What are the correct naming conventions?</p>

<p>I saw an example here: <a href="https://github.com/wbrowar/craft-3-adminbar/blob/master/src/services/EditLinks.php#L48" rel="nofollow noreferrer">https://github.com/wbrowar/craft-3-adminbar/blob/master/src/services/EditLinks.php#L48</a>,  but this did not work for me.</p>

<p>But when I call the predefined service from the pluginfactory: <code>FacebookPageConnector::$plugin-&gt;facebookPageConnectorService-&gt;exampleService()</code>,  it works fine .</p>

<p>here images with my code</p>

<p><a href="https://i.sstatic.net/jgDFn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jgDFn.png" alt="enter image description here"></a></p>

<p><a href="https://i.sstatic.net/Du5xC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Du5xC.png" alt="enter image description here"></a></p>

<craft3>
Craft 3 Call Own Service
# Craft 3 Call Own Service

(Asked by: username_0 on 2017-03-02)

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

**Tags:** craft3

---

## 3 answers

### Answer by username_1 on 2018-02-02. Score: 2

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.


---

### Answer by username_2 on 2017-03-02. Score: 1

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.

> **Comments:**
> **username_0**: i have a FacebookPageConnectorEventsService.php file  
> **username_2**: What's the name of the class in that file?  
> **username_0**: Same like filname but without php  
> **username_0**: 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   
> **username_2**: 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.  
> **username_0**: i added my code...  i created a new plugin with : https://pluginfactory.io/ and as long i use the service i created there it works, if i change the class/file names it does not work anymore ... are there something i forgot about?  

---

### Answer by username_3 on 2018-07-02. Score: 0

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.

> **Comments:**
> **username_4**: Are you saying there is something wrong with the scaffolding code on pluginfactory.io ? I'm pretty sure it's correct...?  
> **username_3**: No - on digging further the composer.json file was specifying service names in the extra components section.  

---

