I always thought of them as kind of "libraries" I could distribute and which others could integrate into their apps. And if I think of "libraries" which I include into one of my projects, I also think of using the classes that come with that "library", I think of aggregating and specializing them, using them the same way I use the classes that come with yii itself.
But now that I started using modules, it turned out, that this isn't as straight forward as I thought it was. It might well be a problem with the design of my module or the classes within, but the more I think about it, the more yii's modules look like "services" to me. I searched a lot through the forum, the guide and the wiki, on how to best use modules or components that come with them. The basic answer is something like this:
The same is true for controller actions that are invoked using an url route. The application knows which module to load, creates the controller and runs the action.
This is all about accessing an API of a black-box, which is basically how I think of "services". You call methods on them, provide data as parameters, they somehow process that data and return a result. How they do the processing doesn't matter, you don't look inside.
So side by side:
"libraries" define a set of classes you can use.
"services" define an API you can use.
Accessing a module through its API is straight forward and seems to be the recommended way.
But how about using a class of a module from somewhere outside that module? My experience is, that doing it can work, but causes problems as soon as the classes rely on any configuration or initialization of their parent module.
So how do you use or see them? Do you think it's best practice to distribute modules as "libraries" with the intention to access their classes? Or do you think they should better be used as services by only interacting with the API they provide?
I'd really appreciate your thoughts on this.