I am working on a Zend PHP project and I’m trying to separate out the code into a custom library, for example “Custom”. At present this mainly consists of some custom forms.
My folder structure is as follows.
/project root
/Library
/Custom
/Forms
/Account
/Login.php
Base.php
/Zend
...
The Login.php and Base.php have the following naming conventions:
class Custom_Form_Account_Login extends Custom_Form_Base
{
}
class Custom_Form_Base extends Zend_Form
{
}
Finally, I placed the following line in my application.ini file
autoloaderNamespaces[] = "Custom_"
Then to create the form, I have this in the controller…
$form = new Custom_Form_Account_Login();
However when I load the page, I get an error telling me that Custom_Form_Account_Login cannot be found. The include path is displayed and I can see that “/project root/Library” is there so I’m a bit confused as to why the class cannot be found.
I’ve tried a number of different lines in the application.ini and I have restarted the server upon making changes yet the error still persists.
Other lines I’ve tried include:
autoloadernamespaces[] = "Custom_" //All lowercase
autoloaderNamespaces[] = "Custom" //Without the underscore
autoloaderNamespaces.custom = "Custom_"
autoloaderNamespaces.0 = "Custom_"
As mentioned I am using Zend 1.12. I would ideally like to configure this in the .ini file.
Your folder name is
Forms(plural) but the class name usesForm(singular). In the context you are describing, these need to be the same.Form(singular) is probably better as it mirrors the ZF structure.