Question

I am making this notification service which provides an api. Apis are actually static functions of one class 'Notifications'. One of the api functions is:getNotifications.

I need to access this class like this way:

mydomain/notification/getNotifications/$userId

I know I can make a module, or a controller, but I don't think this is the proper shape for a simple service component. Is there any other way around in yii?

Was it helpful?

Solution

You need a controller, even if you are thinking about modules, the module would need a controller to handle HTTP Request, which is what they are for.

You can make your component "plugable" by providing just the component and let the users use it however they want, detaching it from the "url" concept if they want to, like using the Notifications object as part of a CLI.

You can also provide a controller with the component, whatever you desire, depending on what the component needs to do, to me it looks like you can shit it without the controller, and just let the user's handle that the best way it fits to them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top