I'm trying to integrate this amazing calendar in my project. I get trouble with the service thing. I'm using this kind of structure:
application/
modules/
agenda/
controllers/
CalendarController.php
models/
services/
CalendarService.php
views/
filters/
helpers/
scripts/
calendar/
view-calendar.php
module2/
module3/
I route this in my application.ini this way:
resources.router.routes.agenda.route = /apps/agenda/
resources.router.routes.agenda.defaults.module = agenda
resources.router.routes.agenda.defaults.controller = calendar
resources.router.routes.agenda.defaults.action = view
I pointed my browser on, and I obtained this message:
Message: Invalid controller class ("Agenda_CalendarController")
I fixed it with my Agenda_ suffix and refreshed my browser. Obtained this:
Message: Controller "Agenda_CalendarController" is not an instance of Zend_Controller_Action_Interface
So I instanced it with "extends Zend_Controller_Action". Obtained this: :-)
Fatal error: Class 'Service_Calendar' not found in /home/[PATH TO MY APP FOLDER]/application/modules/agenda/controllers/CalendarController.php on line 30
I can't figure out what's going wrong. Someone have a hint or two for me :-)
Note: I do not know if that means anything, but I use NetBeans and if I press CTRL while hover a class method of service in the controller class; related popup informations are correct.
Solution: Thanks guys, You gave me the path to go further. My modules bootstraping wasn't set properly. with your hints I found this post from Bob Allen, where he describes the same problem.
When you know what you're searching for... :-)
Thanks, my problem is fixed and I know a bit more!
The naming convention for a controller isn't the same for model/service/view etc., in the sense that you needn't prepend the type in the filename, as you would with a controller. They must follow the basic autoloading name-to-path schema.
So, the declaration for you service would be: Agenda_Service_CalendarService
, because that maps to modules/agenda/services/CalendarService.php
(note the inflection - from the services
folder to the _Service_
singular - that's ZF working and it happens for models, too).
Also make sure you've properly initialized the module (having its own Bootstrap.php file, set up in application.ini).
PS: NetBeans knows where your class is, because it scanned the files and saw the declaration, not the logical inclusion of that class.