# Registering multi classes in one PHP extension

- Thread: https://externals.io/message/1479
- Original archive: https://news-web.php.net/php.internals/1479
- Started by Ptker on 2003-05-13T15:38:40+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1479 — Ptker — 2003-05-13T15:38:40+00:00

URL: https://externals.io/message/1479#1479

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.

---

## #1480 — Andrey Hristov — 2003-05-13T15:47:38+00:00

URL: https://externals.io/message/1479#1480 · In reply to: #1479

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.
>
> Any manual or tutorial about that topic?
>
> Thanks.
