[PHP-DEV] PHP Extension Help
Hi, Before starting up on this email, please be aware that I'm a newbie in C programming and especially in PHP extension coding. I tried researching about my doubt (and even talked with Joey Smith) but couldn't really have a definite answer. My ultimate goal for my little PHP extension is to try to learn C programming and also try to create a C extension to replace the use of the PHPLIB template class. I want to be able to basically create my extension and then 'plug-in' into my code and have it work as the PHPLIB template class would work. At first I tried creating an internal class like 'Directory' and have it somehow be able to do : $t = new JTemplate; // or something similar After speaking with Joey, I learned that you cannot do that (is this true?) because the 'new' operator doesn't look for built-in functions. However, I remember PHP-GTK and how you could do something like this: $win = new GtkWindow(); Isn't this 'GtkWindow' an example of how to register a built-in class and then have the code instantiate it normally as you would do it with a normal PHP based class ? (again, be nice. I'm a newbie :) Anyway, if someone could answer this simple question it would be very appreciated. Cheers, Joao -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP Extension Help
this is a good starting place http://www.php.net/manual/en/zend.php although it doesnt cover the class stuff that well (which can be done : ming, domxml, gtk, xmms - to name a few that do it ) - for a nice example have a look at the xmms extension http://cvs.php.net/cvs.php/pear/PECL/xmms This illustrates class and functional creation, as a side suggestion it may be worth calling your class HTML_Template_XX as this would fit in better with the PEAR naming of classes.. regards alan Joao Prado Maia wrote: Hi, Before starting up on this email, please be aware that I'm a newbie in C programming and especially in PHP extension coding. I tried researching about my doubt (and even talked with Joey Smith) but couldn't really have a definite answer. My ultimate goal for my little PHP extension is to try to learn C programming and also try to create a C extension to replace the use of the PHPLIB template class. I want to be able to basically create my extension and then 'plug-in' into my code and have it work as the PHPLIB template class would work. At first I tried creating an internal class like 'Directory' and have it somehow be able to do : $t = new JTemplate; // or something similar After speaking with Joey, I learned that you cannot do that (is this true?) because the 'new' operator doesn't look for built-in functions. However, I remember PHP-GTK and how you could do something like this: $win = new GtkWindow(); Isn't this 'GtkWindow' an example of how to register a built-in class and then have the code instantiate it normally as you would do it with a normal PHP based class ? (again, be nice. I'm a newbie :) Anyway, if someone could answer this simple question it would be very appreciated. Cheers, Joao -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP Extension Help
The new operator works fine for builtin functions. Look at the domxml extension (INIT_*) for some hints. Fab. - Original Message - From: Joao Prado Maia [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 8:10 PM Subject: [PHP-DEV] PHP Extension Help Hi, Before starting up on this email, please be aware that I'm a newbie in C programming and especially in PHP extension coding. I tried researching about my doubt (and even talked with Joey Smith) but couldn't really have a definite answer. My ultimate goal for my little PHP extension is to try to learn C programming and also try to create a C extension to replace the use of the PHPLIB template class. I want to be able to basically create my extension and then 'plug-in' into my code and have it work as the PHPLIB template class would work. At first I tried creating an internal class like 'Directory' and have it somehow be able to do : $t = new JTemplate; // or something similar After speaking with Joey, I learned that you cannot do that (is this true?) because the 'new' operator doesn't look for built-in functions. However, I remember PHP-GTK and how you could do something like this: $win = new GtkWindow(); Isn't this 'GtkWindow' an example of how to register a built-in class and then have the code instantiate it normally as you would do it with a normal PHP based class ? (again, be nice. I'm a newbie :) Anyway, if someone could answer this simple question it would be very appreciated. Cheers, Joao -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP Extension Help
On Thu, 27 Jun 2002, Alan Knowles wrote: this is a good starting place http://www.php.net/manual/en/zend.php Yes, I looked on the manual before asking. There isn't a good introduction on how to do what I want to do in there, and thats why I asked around before sending the email here. although it doesnt cover the class stuff that well (which can be done : ming, domxml, gtk, xmms - to name a few that do it ) - for a nice example have a look at the xmms extension http://cvs.php.net/cvs.php/pear/PECL/xmms While I see the lines on xmms.c to create and register the new 'xmms' internal class, I don't see in here: http://cvs.php.net/co.php/pear/PECL/xmms/xmms.php?r=1.1 the code to actually do: $xmms = new xmms; // or something like this This illustrates class and functional creation, as a side suggestion it may be worth calling your class HTML_Template_XX as this would fit in better with the PEAR naming of classes.. Again, what I really wish to do is create a plug-in replacement for PHPLIB's Template class. I already have a huge codebase that uses PHPLIB' Template class and would like to create an extension that would make it possible to just remove the calls to 'include(Template.php)' from my code and have the code use my C extension class instead. Since I'm not planning on contributing this to PEAR and that I need the specific 'Template' class name, your suggestion is not appropriate ;) Thanks, Joao -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DEV] PHP Extension Help
Ack, sorry. I just found xmms's implementation of the class on the xmms.c file. Seems like it is exactly what I was looking for. Thanks for the pointers, I appreciate it. Cheers, Joao -- PHP Development Mailing List http://www.php.net/ To unsubscribe, visit: http://www.php.net/unsub.php