0

I've Created an application with these details :

1- zf create project MyApp

2- zf create module admin

3- zf create controller Index 1 admin

MyApp/application/modules/admin/controllers/IndexController.php :

class admin_IndexController extends Zend_Controller_Action
{

    public function init()
    {
        error_reporting(E_ALL);
        ini_set('display_errors', 'On');
    }

    public function indexAction()
    {

        $aa = new Admin_Model_DbTable_Posts();

    }

}

application.ini :

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0 
includePaths.library = APPLICATION_PATH "/../library" 
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap" 
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

MyApp/application/modules/admin/models/DbTable/Posts.php :

class Admin_Model_DbTable_Posts extends Zend_Db_Table_Abstract    
{
    public function init()
    {

    }
}

In this point I get the error :

Fatal error: Class 'Admin_Model_DbTable_Posts' not found in /var/www/MyApp/application/modules/admin/controllers/IndexController.php on line 16

and When i put this line on application.ini

resources.modules[] =

And add bootstratp.php in admin folder with these content

class Admin_Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

}

After a long period of requesting , i get this error :

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

what should i do to make it work?

3 Answers 3

1

Some helpful tips for you

  • Explicitly load the modules in the application.ini with :
    resources.modules[] = "admin"
    resources.modules[] = "default"
  • Make sure that you use double quotation " and not single quotation 'for string literals in your application.ini file.

  • If Admin_Model_DbTable_Posts is not found then the zend_autoloader or the include path is not complete. You can set the zend autoloader to use the fall back option with the following code inside the Bootstrap.ini

protected function _initAutoload()
{
    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace(array('Admin_'));
    $autoloader->setFallbackAutoloader(true);
    $autoloader->suppressNotFoundWarnings(false);   
    return $autoloader;
}

Hope it helps!

5
  • any additional line to appication.ini begin with resources.modules[] cause some kind of loop result in "HTTP Error 500 (Internal Server Error)" , I don't know why ? and in /var/apache2/error.log is empty !
    – user1438910
    Dec 28, 2012 at 13:11
  • this is very strange! Which URL(s) result in this strange behavior. I want to think that perhaps .htaccess has something to do with it. By the way, what do you mean by"kind of loop"?
    – shawndreck
    Dec 28, 2012 at 13:22
  • mydomain.com/admin return this result. I should said it send request and it take too long , instead of loop .
    – user1438910
    Dec 28, 2012 at 13:39
  • just in any case, what is in your main .htaccess file? This is particularly strange that no log remains of this error.Still trying to think of something!
    – shawndreck
    Dec 28, 2012 at 13:55
  • I am pretty sure that is not htaccess problems .
    – user1438910
    Dec 28, 2012 at 15:33
1
class Admin_Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{

}

should be

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{

}

Using Module_Bootstrap should work to provide module assets to your application. I wouldn't make any other changes.

Ignore the previous answer, good advice if you are using none standard setup, but your setup is apparently standard. You may have to capitalize admin in admin_IndexController, but maybe not.

1
  • thank's, i get ride of the annoying error 500 , but i stuck in the Fatal error: Class 'Admin_Model_DbTable_Posts' not found in /var/www/MyApp/application/modules/admin/controllers/IndexController.php on line 18
    – user1438910
    Dec 28, 2012 at 14:29
0

I Solved the problem by putting together shawndreck and RokyFord answers . thanks to both of theme . I actually over configed application.ini file . I did the following :

I have Recreated another simple project and it work fine so i compare two project files.

Then i understand that with changing

Zend_Application_Bootstrap_Bootstrap

to

Zend_Application_Module_Bootstrap

and putting resources.modules[] = "admin" in the application.ini , it works .

  • Some times OVER CONFINING the application.ini cause a lot of problems in Zend-Framework -at least for me, this happen alot-.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.