views:

239

answers:

1

I want to know where is the best place to put the model classes inside a Zend Framework project. I heard that inside the library is the better place with versions < 1.8. And with version 1.8 we have the ResourceLoader so we can put inside the modules dir.

What's your method? What's the best practice?

+2  A: 

Check out this document outilinig several typical directory layouts: Choosing Your Application's Directory Layout

My setup looks like this:

app/
    controllers/
    forms/
    lib/
    models/
    views/
    config.ini
lib/
sql/
var/
web/
    css/
    img/
    js/
    .htaccess
    index.php

I use Zend Autoloader to automatically include model classes. The very top of my index.php file is:

$paths = array(
    '/usr/share/php/ZendFramework/library',
    '../app/models',
    '../app/lib',
    '../app/forms',
    '../app/models',
    '../lib',
    get_include_path()
);
set_include_path(implode(PATH_SEPARATOR, $paths));

// bootstrap
require 'Zend/Loader.php';
Zend_Loader::registerAutoload();

Works well with Zend Framework 1.7 as well as 1.8.

Michał Rudnicki