I have a similar setup... Here's what I've done... In the bootstrap, I loop through all of my modules, and add the models folder to the inclusion path....
$paths[] = BP . DS . 'app' . DS . 'modules'; $dir = new DirectoryIterator($paths[0]); foreach($dir as $file){ if ($file->isDot() || !$file->isDir()) { continue; } $moduleName = $file->getFilename(); $moduleDir = $file->getPathname(); if (preg_match('/^[^a-z]/i', $moduleName) || ('CVS' == $moduleName)) { continue; } $paths[] = $moduleDir.DS.'models'; } $paths[] = BP . DS . 'lib'; set_include_path( implode(PS, $paths) . PS . get_include_path()); So, at this point, /app/modules/core/models is within my inclusion path. Now, I create a subfolder within models called Core ( same module name, just uppercased ). Lastly, I now place all my models that I want within the core module, within : /app/modules/core/models/Core/User.php /app/modules/core/models/Core/Website.php /app/modules/core/models/Securepay/Payment.php Now, I am able to utilize spl_autoload with the proper syntax ( Core_User ). All of my models that are db-base will extend from my lib model ( Project_Db_Table_Abstract ). With this, I have the ability to declare the tablename as either the classname, or maybe a variation. Another cool thing I did, was create something like this: final class Project { public static function getModel($classId,$args=array()){ $classArr = explode('/', trim($classId)); $group = $classArr[0]; $class = !empty($classArr[1]) ? $classArr[1] : null; $className = $group.'_'; if (!empty($class)) { $className .= '_'.$class; } $className = uc_words($className); if (class_exists($className)) { return new $className($args); } } So you ask, how does this actually benefit? Project::getModel('core/website')->insert($data); kinda cool. Anyway, I hope this helps a bit. Ghrae wrote: > > I have a lot of tables in my database. And I could make a model for each > one, but at that point, the folder gets a bit unmanageable. So in the > effort of organizing it a bit: > > 1) How do I create sub folders under the model folder such that I can use > the Zend_Loader::loadClass to find and load them? > > 2) some of the tables have underscores (i.e. acl_users). I would like to > put all ACL tables in an ACL folder. At that point I don't care if the > individual models are named Users or ACL_Users or whatever, as long as > they are grouped and the name is intuitive. What naming convention should > I use for the models once in the sub folders > > 3) Does naming tables with underscores cause any issues with Zend's > current naming conventions? And if so, is there a better or different > naming convention that anyone would like to suggest? > > This is a pet project of mine that I'm reworking in a development > environment in an effort to learn Zend and teach me better programming > habits (most of my PHP has been self-taught by using examples across the > web and most of those do not teach good habits of programming). > -- View this message in context: http://www.nabble.com/Models-and-folder-grouping-tp19412763p19449359.html Sent from the Zend Framework mailing list archive at Nabble.com.