sasori Posted August 22, 2010 Share Posted August 22, 2010 I added a new folder inside the library folder and named it as "Form" ( so now I have two folders, the Form & Zend ) inside the "Form" folder, I added a file named "Elements.php" inside the "Elements.php" I have named the class as class Elements{} now the question is, How will I use that Elements class to another class without having to use the require() function just like the Zend libraries ? Quote Link to comment https://forums.phpfreaks.com/topic/211405-how-to-use-different-library-in-zf/ Share on other sites More sharing options...
trq Posted August 22, 2010 Share Posted August 22, 2010 You just need to register your namespace with the autoloader. require_once 'Zend/Loader/Autoloader.php'; Zend_Loader_Autoloader::getInstance()->registerNamespace('Form_'); Quote Link to comment https://forums.phpfreaks.com/topic/211405-how-to-use-different-library-in-zf/#findComment-1102246 Share on other sites More sharing options...
sasori Posted August 22, 2010 Author Share Posted August 22, 2010 nothing happened, there's still an error that the class cannot be found.. am I doing the right thing? 1) the file name is Elements.php 2) the class name is Elements.php 3) folder name is "Form" 4) registerednamespace("Form_") 5) called the file to another class as, new Form_Elements(); is the correct or ? Quote Link to comment https://forums.phpfreaks.com/topic/211405-how-to-use-different-library-in-zf/#findComment-1102247 Share on other sites More sharing options...
trq Posted August 22, 2010 Share Posted August 22, 2010 2) the class name is Elements.php That isn't even valid php. The class would need to be named 'Form_Elements'. Quote Link to comment https://forums.phpfreaks.com/topic/211405-how-to-use-different-library-in-zf/#findComment-1102248 Share on other sites More sharing options...
sasori Posted August 22, 2010 Author Share Posted August 22, 2010 sorry, i mistyped .php, on my reply how about when using it to another class ? is it "$var = new Form_Elements()" or "$var = new Form_Element" ? Quote Link to comment https://forums.phpfreaks.com/topic/211405-how-to-use-different-library-in-zf/#findComment-1102249 Share on other sites More sharing options...
sasori Posted August 22, 2010 Author Share Posted August 22, 2010 ok nevermind..it worked...thanks for the Help.. ++rep for you Quote Link to comment https://forums.phpfreaks.com/topic/211405-how-to-use-different-library-in-zf/#findComment-1102250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.