How to create PHP extension ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iceberg
Forum Newbie
Posts: 3
Joined: Wed Oct 30, 2002 5:52 am

How to create PHP extension ?

Post by iceberg »

Hi,
I want to write an independent extension for PHP. This extension should not be compiled into PHP. It should be dynamically loaded in PHP script.
The platform is to be Linux. Can someone tell me the broad steps to do so ?

Thanks in advance,
iceberg.
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

here is a good Table of Contents to get you going: http://www.php.net/manual/en/zend.php
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

there are several modules within the source-distribution of php.
Take a look at those that can be configured via with-xyz-shared.
i.e. the tokenizer module. note:

Code: Select all

/* {{{ tokenizer_functionsї]
 *
 * Every user visible function must have an entry in tokenizer_functionsї].
 */
function_entry tokenizer_functionsї] = {
	PHP_FE(token_get_all,	NULL)
	PHP_FE(token_name,	NULL)
	{NULL, NULL, NULL}	/* Must be the last line in tokenizer_functionsї] */
};
/* }}} */

/* {{{ tokenizer_module_entry
 */
zend_module_entry tokenizer_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
	STANDARD_MODULE_HEADER,
#endif
	"tokenizer",
	tokenizer_functions,
	PHP_MINIT(tokenizer),
	PHP_MSHUTDOWN(tokenizer),
	PHP_RINIT(tokenizer),		/* Replace with NULL if there's nothing to do at request start */
	PHP_RSHUTDOWN(tokenizer),	/* Replace with NULL if there's nothing to do at request end */
	PHP_MINFO(tokenizer),
#if ZEND_MODULE_API_NO >= 20010901
	"0.1", /* Replace with version number for your extension */
#endif
	STANDARD_MODULE_PROPERTIES
};
/* }}} */

#ifdef COMPILE_DL_TOKENIZER
ZEND_GET_MODULE(tokenizer)
#endifif
in tokenizer.c
iceberg
Forum Newbie
Posts: 3
Joined: Wed Oct 30, 2002 5:52 am

it worked

Post by iceberg »

thanks a lot. using the shared flag worked. it was the only missing thing.
Post Reply