1
votes

I have a problem in creating a modular application with zend framework, I followed more tutorials and modules studied several times, but I always get the same error.

The structure of my application is in the following figure.

+Site

  • application

    +configs

    +modules

      admin
    
      default
    

    +Bootstrap.php

  • docs

  • library

  • public

  • test

In each module I have a class that extends the class Zend_Application_Module_Bootstrap, and are respectively:

  • Admin_Bootstrap
  • Default_Bootstrap

My application.ini file is as follows:

[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

;module support
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""
resources.frontController.params.prefixDefaultModule = "1"
resources.frontController.defaultModule="default"
;end module support
[staging : production]

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

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

If I try to get to the url http://localhost/site.it/public/ it's ok, but if i try to get to the url http://localhost/site.it/public/admin I get the error The requested URL http://localhost/site.it/public/admin was not found on this server.

The file .htaccess is composed of:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

What's wrong?

1
Do you have a htaccess file in public? If so please edit your question to include its contents. - Tim Fountain
Yes I have .htaccess file - Gioacchino Del Prete
It's a generic 404 error no? Sounds like folder permissions or host setup. Backtrack. Try something simple like an index.html in your site's root and nothing else. Can you browse to that? - ficuscr
There are no mistakes inserting an index.html file in the root of the application - Gioacchino Del Prete
Sounds like your htaccess file is not being used. Check your vhost configuration for the AllowOverride directive. - Tim Fountain

1 Answers

0
votes

You better use an alias like siteit.localhost or something so you don't need to write public everytime. This may solve your problem but i need to add something; in module admin, do controllers have Admin before their name?

like

class Admin_IndexController extends Zend_Controller_Action {...

By the way in our code we include every folder in module like this, (remove the subview line if you don't use subviews)

define('ROOT_DIR', realpath(dirname(__FILE__) . '/../'));

$modules = array('admin', 'foo' , 'asdasd');

foreach ($modules as $module) {
    set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . '/application/modules/' . $module . '/models');
    set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . '/application/modules/' . $module . '/forms');
    set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . '/application/modules/' . $module . '/views');
    set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . '/application/modules/' . $module . '/controllers');
    $subview->addBasePath(get_include_path() . PATH_SEPARATOR . ROOT_DIR . '/application/modules/' . $module . '/views');
}