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 ? 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_'); 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 ? 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'. 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" ? 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 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
Archived
This topic is now archived and is closed to further replies.