This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Indie
Indie

So, I'm trying to figure out Service Providers and how to best use them for my site. I have a couple of custom classes that I want to include to my plugin (used by the plugin's frontend components), but the manual is a bit fuzzy about where exactly the .php files should be placed? The example shows System\ServiceProvider so does that mean October looks for the SP's in the modules/ directory? Is there a way to tell it to look for it, for example, inside the plugins directory?

Daniel81
Daniel81

Inside the plugin boot() function, you can use

App::register('Path\To\ServiceProvider');
joseph.d
joseph.d

Sorry to revive an old thread.... but I have a question about this.

Registering a service provider seems pretty straightforward, but if I am using a custom service provider that is not part of a composer package then where am I supposed to place it within my plugin folder structure for October to pick it up when I do App::register()?

code200.miha
code200.miha

@joseph.d where did you decide to put it? :) I am thinking about the same thing, for now having it in root plugin folder which I dont think is the best option

joseph.d
joseph.d

@code200.miha I just made a folder called "providers" and put it in the root plugin folder.

Thinking about it, there isn't really anywhere else it can go except in the plugin root.

JeffGoldblum
JeffGoldblum

When registering service providers, you provide the namespace and class name of the service provider. October uses this information to find the correct file just like it would with a simple use Vendor\Plugin\Classes\ExampleClass;

1-6 of 6

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.