Student
Student

Reputation: 1863

How to access my modules in Zend?

I created a project test using zend tool. Then I created a module test. Then I created TestController in test module.

Now when I access test.dev/test/test/index, it show following error.

Message: Invalid controller specified (test) 

How to enable my modules in zend. I think I have to enable my application.ini or Bootstrap.php

Upvotes: 1

Views: 669

Answers (2)

Student
Student

Reputation: 1863

With the help of accepted answer I found:

I just added the following line in application.ini and all modules are accessible using URLs:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

So now my application.ini is like this:

[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
;includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

Note:

moduleDirectory statement should be after controllerDirectory statement.

Help:

Upvotes: 1

Ivan Krechetov
Ivan Krechetov

Reputation: 19220

Add this to your application.ini

resources.modules[] =
resources.frontController.defaultModule = test
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules/"

You may not set the default one. Then all the URI-s will be /modulename/controllername/actionname. Having a default module allows you to omit the "/modulename" part.

For other objects access set the includePath-s and autoloadernamespaces in application.ini:

includePaths.library = APPLICATION_PATH "/../library"
autoloadernamespaces.form = "Form_"

And follow the Zend naming conthention then in this dir. Say, Form_User_Login class must be defined in APPLICATION_PATH . "/../library/Form/User/Login.php"

Upvotes: 4

Related Questions