0

I've read a book titled zend framework: beginner's guide. It was mentioned that it's best practice to create modules and categorize things.

I've added the modules directory to the application directory and moved views,controllers and models directory into it. The structure is as below:

application

  • configs
  • modules
  • Bootstrap.php

when I pop open the browser and surf to the following URLs:

localhost/square/default/index/index

OR

localhost/square/public/default/index/index

I get not found error message. I've changed the configuration file (application.ini) as below:

resources.frontcontroller.controllerDirectory = APPLICATION_PATH "/modules/default/controllers"
resources.frontcontroller.params.displayExceptions = 0
resources.frontcontroller.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""

I've read the following questions, but that didn't help:

Change Zend Framework Default Module

Zend Framework not include the default module in url

2 Answers 2

1

Just use this instead :

resources.frontcontroller.controllerDirectory = APPLICATION_PATH "/controllers"

EDIT :

I noticed that you use localhost/square/ to access your pages. You have to setup a virtual host to fix your problem since the router need it to work properly.

See : http://framework.zend.com/manual/1.12/en/learning.quickstart.create-project.html#learning.quickstart.create-project.vhost

4
  • My app path is not as you said. I've moved them all into the modules directory.
    – Alireza
    Sep 6, 2013 at 17:37
  • In the App directory I don't have controllers folder.
    – Alireza
    Sep 6, 2013 at 17:38
  • I understood your app path. I just said that you have to remove "/modules/default" since it is automatically added. see framework.zend.com/manual/1.12/en/… Sep 6, 2013 at 17:52
  • I still receive 404 not found. What is the issue? Do you need all the directories structure?
    – Alireza
    Sep 6, 2013 at 18:03
1

this should work.

resources.modules[] = ""    
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.defaultModule = "default"
resources.frontController.defaultControllerName = "index"
resources.frontController.defaultAction = "index"
resources.frontController.env = APPLICATION_ENV
4
  • I still access my site through http://localhost/square/public/index.php, but your method to access through http://localhost/square/default/index/index is not working! What can be the issue? Do you need all the directories structure?
    – Alireza
    Sep 6, 2013 at 17:44
  • You didn't setup virtual host of project. By default, index.php is in public folder. In this case, go localhost/square/public/default/index/index and see the result. If you want to remove public from url, try setup a virtual host, more here framework.zend.com/manual/1.12/en/… or put index.php in the root of project then edit your config path, but this solution is not recommended because of security issues. i speak English not well, sorry. Sep 7, 2013 at 0:36
  • Although I added the public part, the same error(404 not found) happened!
    – Alireza
    Sep 7, 2013 at 4:38
  • hello. mediafire.com/?jq8rlxuglb8tbm8 this is my sample configuration (no virtual host setup), hope that help! Sep 7, 2013 at 6:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.