As of March '09 the ZF thought leaders still seem to be debating the best ways to organize everything. There is a scaffolding-generator as a part of Zend_Tool slated for release in ZF v1.8. It's currently in the incubator, I tried it last week and it works, but there are not many components generated in its current state.
From the examples I've seen it seems that they are best managed separate from the models they interact with (this is from Zend Framework In Action):
/application
/modules/
/default
/controllers
/forms
ContactForm.php
LoginForm.php
RegisterForm.php
SupportForm.php
/models
Comment.php
User.php
Users.php
/views
/admin
/controllers
/views
However, I've also seen structured with the forms below the model directory. Matthew Weier O'Phinney shows how to use them for validation on models themselves:
/application
/modules/
/default
/controllers
/models
Comment.php
User.php
/Form
Comment.php
Login.php
Register.php
/views
/admin
/controllers
/views
To have your files automatically included be sure to name your classes using the underscore model.
For example, when Zend_Loader sees
class RegisterController extends Zend_Controller_Action
It looks in the php include_path for:
Zend/Controller/Action.php
Similarly, assuming the first structure above, if we include the 'default' module in our include_path:
# bootstrap.php
$rootDir = dirname(dirname(__FILE__));
define('ROOT_DIR', $rootDir);
set_include_path(get_include_path()
. PATH_SEPARATOR . ROOT_DIR . '/library/'
. PATH_SEPARATOR . ROOT_DIR . '/application/modules/default/'
);
include 'Zend/Loader.php';
Zend_Loader::registerAutoload();
You name your classes:
Forms_ContactForm
Models_User
Some programmers choose to put most of their files in the library so they don't have to add extra include paths:
/library
/My
/Form
Contact.php
Assuming the library folder is included, the class above would be named:
My_Form_Contact
Best of luck! -Matt