I just started to migrate my main application to ZF 1.8.x, I love
Zend_Application since it promotes reuse and configuration made all using
config.ini. (A note about this, IMHO you should standardize also the name
and the location of the configuration file).
I rewrote all my previous bootstrap code using only the configuration file,
so my bootstrap class now it's almost empty. The only thing I cannot make
work is the autoloader since the documentation about that is pretty
undetailed.
What I want to do is to standardize my classes using a consistent namespace
convention, since i have to refactor most of the classes of my app, I want
to ask which is the better way to do it before starting.
Which I am trying to do is to have modules resources (such as forms, models
and so on) inside respective module directory and call a class something
like Admin_Model_User or Admin_Form_Login in a structure like this one:
application
+ modules
+ admin
+ controllers
+ forms
+ Login.php
+ modules
+ User.php
+ views
and a library direcotory with common code shared and used across
applications with classes named something like Company_Exception_Permission,
Company_Plugin_Foo, Company_View_Helper_Date, Company_Form_Validator_Bar or
Company_Action_Helper_Log in a structure like this one:
application
+ library
+ Company
+ Action
+ Helper
+ Log.php
+ Exception
+ Permission.php
+ Form
+ Validator
+ Bar.php
+ Plugin
+ Foo.php
+ View
+ Helper
+ Date.php
How to achieve this using Zend_Loader_Autoloader?? I'm pretty confused about
its usage.
And one more question, in the configuration file I loaded my plugins and
action helpers in this way:
;resources.frontController.plugins.10 = "Company_Plugin_Translator"
;resources.frontController.plugins.20 = "Company_Plugin_DbProfiler"
;resources.frontController.actionhelperpaths.Zenit_Action_Helper_ =
APPLICATION_PATH "/var/lib/helpers/action"
and in the Bootstrap file I've only this:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
public function _initAutoloader() {
$moduleLoader = new Zend_Application_Module_Autoloader(
array ('namespace' => 'Company_', 'basePath' =>
APPLICATION_PATH .
'/var/lib'));
return $moduleLoader;
}
}
So it found Company_Plugin_Translator under var/lib/plugins path, but I
think this is wrong, because in this way I cannot put resources into modules
directory under application.
And the last thing: in the index.php file I have this
// Ensure library/ is on include_path
set_include_path(
implode(PATH_SEPARATOR,
array (
realpath(APPLICATION_PATH .
'/var/lib'),
get_include_path())));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV,
array (
'config' => APPLICATION_PATH .
'/configs/application.ini',
'pluginPaths' => array
('Company_Application_Resources' =>
'resources')));
// run the application
$application->bootstrap()->run();
Since I wrote a couple of resource classes, for example to configure
logfiles properties via application.ini and I want to reuse them as well, in
a new application, I'd like to keep them under the Company directory of the
lib folder instead of the resources folder
So instead of
application
+ var
+ lib
+ resources
+ Log.php
I'd like:
application
+ var
+ lib
+ Company
+ Application
+ Resources
+ Log.php
I know these are a lot of questions, but please help me, because I'm
completly stucked with this thing, and I cannot proceed with development
before I solve it.
Thanks for any help.
--
View this message in context:
http://www.nabble.com/Autoloader-best-practices-tp24045941p24045941.html
Sent from the Zend Framework mailing list archive at Nabble.com.