0

Following is my project structure,

enter image description here

In the bootstrap file, am loading modules like this

protected function _initAutoload() {

        $autoloader = new Zend_Application_Module_Autoloader(array(
         'namespace'=>'',
         'basepath'=>APPLICATION_PATH
        )
        );
        return $autoloader;
    }

When I try to access controller, following error is thrown,

Fatal error: Uncaught exception 'Zend_Loader_Exception' with message 'Resource loader requires both a namespace and a base path for initialization' in

Any idea on this?

APPLICATION.INI

[production]

phpSettings.display_startup_errors = 1

phpSettings.display_errors = 1

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.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

resources.view.doctype = "XHTML1_STRICT"

resources.db.adapter = PDO_MYSQL;

resources.db.params.host = localhost;

resources.db.params.username = root2;

resources.db.params.password = password;

resources.db.params.dbname = zfalbums;

settings.publicFoderPathRelativeToApplicationPath = "../public_html";

settings.skin.name = "default";

settings.cache.enable = false;

Thanks

flex
  • 185
  • 5
  • 19

3 Answers3

0

The namespace should be the name of the module. As you don't show any modules listed, you may not even need the module autoloader. However, try "default" as the namespace, though you may need to prefix everything with this (i.e. class Default_IndexController extends Zend_Controller_Action).

shrikeh
  • 661
  • 9
  • 12
  • 1) Am not using module loader MVC, it is default MVC of ZFW, However when we use ZFW default MVC, I guess, we don't have to create default folder right? – flex Jun 21 '12 at 16:06
0

First: if you are using a reasonably current version of ZF this is redundant code. Comment it out and things should work.

Second: the only module you are showing in your structure would be 'default'.

It looks like you might be working with Rob Allens ZF 1.x tutorial, if so make sure you have the current version.

To enable modules check this out (from Rob Allen)

[EDIT] To fix your database issue make sure you have at least these lines in your application.ini:

;Database Settings
;*****************
resources.db.adapter = "pdo_Mysql" //your database adapter
resources.db.params.username = "your_username"
resources.db.params.password = "your_password"
resources.db.params.dbname = "your_db_name"

remember this database needs to exist before you try to connect to it (or you could create it with a script). PHPmyadmin works well for easily managing mysql.

RockyFord
  • 8,529
  • 1
  • 15
  • 21
  • 1) Yes am working with Rob allens tutorial! however with zend studio, not with zfw tool 2) Did u mean stay, commenting out of bootstrap.php code 3) if Yes for point 2, Am not getting any values form DB – flex Jun 21 '12 at 16:05
  • yes, comment out the _initAutoload() method in your bootstrap. It should not be required when using zf 1.11. Zend studio should use Zend_tool in the background, Netbeans does something similar. – RockyFord Jun 22 '12 at 09:28
  • If you have further problems post your application.ini. – RockyFord Jun 22 '12 at 09:34
  • sorry the answer hasn't changed, that error is caused by the _initAutoload method in your bootstrap. You don't need that method at this point. For a basic tutorial application your bootstrap does not need any methods (unless the tutorial you are using specifies them). If you have new errors, please post them. – RockyFord Jun 23 '12 at 09:39
  • you may want to restart the tutorial using Zend_tool as described by Rob. I think it's possible that Zend studio is getting in your way by auto generating code that you are not understanding yet. Once you build the project using Zend_Tool you should still be able to edit it in Zend_studio. – RockyFord Jun 23 '12 at 09:45
0

Your getting following error

Fatal error: Uncaught exception 'Zend_Loader_Exception' with message 'Resource loader requires both a namespace and a base path for initialization' in

Because in your bootstrap you've loading base path as 'basepath'=>APPLICATION_PATH this should to be 'basePath' => APPLICATION_PATH

FR STAR
  • 662
  • 4
  • 24
  • 50