Registering multi classes in one PHP extension

php.internals

Ptker

23 years ago
Hi. Any manual about registering multi classes in one PHP extension? Simple example:(register two classes named myapp and mylib) INIT_CLASS_ENTRY(myapp_class, "myapp", myapp_class_functions); myapp_ptr = zend_register_internal_class(&myapp_class TSRMLS_CC); INIT_CLASS_ENTRY(mylib_class, "mylib", mylib_class_functions); mylib_ptr = zend_register_internal_class(&mylib_class TSRMLS_CC); Now I want write the code in php like following: <?php ... $myapp = new myapp(); $myapp->mylib->dosomething(); ... ?> The member mylib of myapp is registered in C code, also is an object by mylib class. How to do? I read some code in ext/(like pear) that contaings that function, but I can hardly understand that code. Any manual or tutorial about that topic? Thanks.

Andrey Hristov

23 years ago
Add a constructor for myapp class in the C code. It should be named myapp. The in the constructor - do getThis() and add property using the add_property_zva() macro. The zval have to a instance of mylib class (use object_init_ex()). Hope this helps, Andrey ----- Original Message ----- From: "Ptker" <ptker@hotmail.com> To: <internals@lists.php.net> Sent: Tuesday, May 13, 2003 6:38 PM Subject: [PHP-DEV] Registering multi classes in one PHP extension
> Hi. > > Any manual about registering multi classes in one PHP extension? > Simple example:(register two classes named myapp and mylib) > INIT_CLASS_ENTRY(myapp_class, "myapp", myapp_class_functions); > myapp_ptr = zend_register_internal_class(&myapp_class TSRMLS_CC); > > INIT_CLASS_ENTRY(mylib_class, "mylib", mylib_class_functions); > mylib_ptr = zend_register_internal_class(&mylib_class TSRMLS_CC); > > Now I want write the code in php like following: > <?php > ... > $myapp = new myapp(); > $myapp->mylib->dosomething(); > ... > ?> > The member mylib of myapp is registered in C code, also is an object by
mylib class. How to do?
> I read some code in ext/(like pear) that contaings that function, but I
can hardly understand that code.