What I want to do:
Create a number of modules with the forms folder inside them.
What I did:
Create a bootstrapper inside the module and added an _initAutoload function with the specific module name as namespace.
For instance, an admin module with the following bootstrapper:
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Admin_',
'basePath' => dirname(__FILE__),
));
return $autoloader;
}
}
My question is:
Is this the correct way of doing what I want? - I tried it without having the admin bootstrapper, but it couldn't find my form, until I added the bootstrapper.
Cheers
Chris
Create a new PHP class named Module inside the –myapp/module/Tutorial/src/ directory and implement the ConfigProviderInterface. Set Tutorial as the namespace for the Module class. Write a public function getConfig in the Module class and return the configuration file for the Tutorial Module.
Zend Framework was created to help ensure that the production of PHP-based web-sites is easier and more maintainable in the long term. It contains a rich set of reusable components including everything from a set of Model-View-Controller (MVC) application components to PDF generation classes.
Zend is an open source PHP framework. It is pure object-oriented and built around the MVC design pattern. Zend framework contains collection of PHP packages which can be used to develop web applications and services. Zend was started by Andi Gutmans and Zeev Suraski.
The autoloader is automatically set up for each module bootstrap. You don't need to configure it manually.
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {}
is all you need.
Then put your forms in /application/modules/admin/forms/
.
Admin_Form_Myform extends Zend_Form {...}
For your custom resources, customize resourceAutoloader:
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{
public function _initAuloload()
{
$resourceLoader = $this->_resourceAuloloader;
// var_dump($resourceLoader);
}
}
Remember to add also in your apllication.ini
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With