2

I have code that is straight forward, but intensive. I would like to compile it into a PHP extension. What is the simplest / best practice for going about that?

I have a Java background, so writing the C / C++ code shouldn't be an issue. I would, however, like to avoid any pitfalls along the way.

A simple tutorial or walk through is something I haven't been able to find. Plenty of examples, but nothing aimed at someone new to doing this.

It looks like a more arduous road then I though, especially with all the lovely C quirks.

Community
  • 1
  • 1
Josh K
  • 28,364
  • 20
  • 86
  • 132

3 Answers3

0

You should try SWIG for generating wrapper for your source code, and then create your extension. It supports various languages like Java, C/C++ and makes it as simple as possible.

A23149577
  • 2,045
  • 2
  • 40
  • 74
0

The PHP Manual and this Zend article seem to cover quite a bit of ground in regards to writing PHP extensions.

Russell Dias
  • 70,980
  • 5
  • 54
  • 71
0

The the tag info for php-extension and in particular, this answer, also linked from there.

Community
  • 1
  • 1
Artefacto
  • 96,375
  • 17
  • 202
  • 225