I have a few small libraries and wrappers written in C (not C++) that I would like to make available to PHP via extensions. I read several tutorials on writing proper PHP extensions and it does not seem to difficult, however I don't want the hassle of maintaining the extensions in addition to the libraries.
I read that SWIG supports building extensions that are compatible with Zend PHP 5, which is perfect for me. However, the support seems to be beta according to the SWIG documentation.
My libraries are pretty common, as a meta example of usage in C:
int main(void)
{
struct libfoo *foo;
char **tmp;
foo = foo_init();
if (foo == NULL) {
fprintf(stderr, "Could not allocate foo\n");
return 1;
}
tmp = foo_parse(foo, "/foo/foo.txt");
......
foo_finit(foo);
}
Does anyone have any experiences to share with using SWIG to make extensions for libraries as simple as this? Does anyone know of any free/open source projects written in C that are using SWIG to make php extensions as an optional part of the build?
Thanks in advance, I'm hoping to get some feedback. If its positive, I'll just devote some time to really getting to know SWIG.. if not, I'll spend the time just making the extensions by hand.