0

I have a Zend Framework modular application set up. One of my modules is called 'frontend' and it is the default module (resources.frontController.defaultModule = "frontend" is in my config file).

I have a form, Frontend_Form_PropertySearch located at /application/modules/frontend/forms/PropertySearch.php and attempting to use it in my controller as follows:

public function searchAction() { $form = new Frontend_Form_PropertySearch(); $form->submit->setLabel('Search'); $this->view->form = $form; } 

However, I'm getting the following error:

Fatal error: Class 'Frontend_Form_PropertySearch' not found in /Users/Martin/Dropbox/Repositories/realestatecms/application/modules/frontend/controllers/PropertiesController.php on line 17

Where am I going wrong?

3
  • Is your appnamespace Frontend or is it something else? See Application Autoloading Commented Jan 11, 2012 at 21:21
  • appnamespace is still set to 'Application' in my config file. Commented Jan 11, 2012 at 21:27
  • In that case BartekR's first method should work. You could shorten it by removing the resourceTypes array if you are using the default Zend Application autoloader mappings. You can also just add it to your application bootstrap as in ZF1 all bootstraps are run regardless of your current module. Commented Jan 11, 2012 at 22:23

2 Answers 2

2

One of solutions could be adding file application/modules/frontend/Bootstrap.php and put this (similar working on one of my projects):

<?php class Frontend_Bootstrap extends Zend_Application_Module_Bootstrap { protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Frontend_', 'basePath' => APPLICATION_PATH .'/modules/frontend', 'resourceTypes' => array ( 'form' => array( 'path' => 'forms', 'namespace' => 'Form', ), 'model' => array( 'path' => 'models', 'namespace' => 'Model', ), ) )); return $autoloader; } } 

Another solution, as described by akrabat: http://akrabat.com/zend-framework/bootstrapping-modules-in-zf-1-8/

// file application.ini resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.modules[] = "" File: /application/modules/frontend/Bootstrap.php <?php class Frontend_Bootstrap extends Zend_Application_Module_Bootstrap { } 

Second one uses default resource autoloader as described in documentation: http://framework.zend.com/manual/zh/zend.loader.autoloader-resource.html#zend.loader.autoloader-resource.module

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure your ini file contains these lines

resources.frontController.moduleDirectory = APPLICATION_PATH "/path/to/your/modules" resources.modules[] = 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.