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

Community
  • 1
  • 1
Alireza
  • 6,497
  • 13
  • 59
  • 132

2 Answers2

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

Fouad Fodail
  • 2,653
  • 1
  • 16
  • 16
  • My app path is not as you said. I've moved them all into the modules directory. – Alireza Sep 06 '13 at 17:37
  • In the App directory I don't have `controllers` folder. – Alireza Sep 06 '13 at 17:38
  • I understood your app path. I just said that you have to remove "/modules/default" since it is automatically added. see http://framework.zend.com/manual/1.12/en/zend.application.available-resources.html#zend.application.available-resources.frontcontroller – Fouad Fodail Sep 06 '13 at 17:52
  • I still receive `404 not found`. What is the issue? Do you need all the directories structure? – Alireza Sep 06 '13 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
Thanh Nguyen
  • 5,174
  • 11
  • 43
  • 74
  • 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 06 '13 at 17:44
  • You didn't setup virtual host of project. By default, `index.php` is in public folder. In this case, go http://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 http://framework.zend.com/manual/1.12/en/project-structure.rewrite.html 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. – Thanh Nguyen Sep 07 '13 at 00:36
  • Although I added the public part, the same error(404 not found) happened! – Alireza Sep 07 '13 at 04:38
  • hello. http://www.mediafire.com/?jq8rlxuglb8tbm8 this is my sample configuration (no virtual host setup), hope that help! – Thanh Nguyen Sep 07 '13 at 06:20