4

In one of our project we are specifically and compulsorily required to create C++ static libraries (.a files) , and then use them in PHP (web Application). We are successfully able to create .a files, now wondering if anyone can help us in identifying how to use them in PHP. The " .a file " will accept some input data, and will return some output that can be used in the web application.

NKS
  • 1,140
  • 4
  • 17
  • 35

1 Answers1

2

Here's a nice tutorial on how to create PHP extensions. I used that in the past and it works well.

https://web.archive.org/web/20150408110240/https://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend

Cybrus
  • 74
  • 13
Simon Germain
  • 6,834
  • 1
  • 27
  • 42
  • 1
    also see http://stackoverflow.com/questions/1311389/getting-started-with-php-extension-development. there is a nice tutorial linked for complete manual development of a php extension – Criss Oct 09 '12 at 13:36
  • Thanks for the response, I have gone through the link earlier also, and once again. But I am looking for a solution which is independent of any framework libraries like zend, also the solution which can work on Windows platform. – NKS Oct 10 '12 at 09:52
  • you cant load native code with php, so you need to create a php extension. -- also, if there is something supporting loading native code from php, it needs to be a c dynamic library (*.dll on windows and *.so on linux). so your options are: create an php extension (easiest way) or search for a dynamic library loader and create a platform specific dynamic library – Criss Oct 11 '12 at 07:11
  • Hi Criss, thanks, I will definately like to go for creating php extension, but for me it seems to be little difficult, as my C++ prog may have some higher degree of mathematics and statics involved refering to several external libraries written in C++, I have gone thru the links like http://devzone.zend.com/1435/wrapping-c-classes-in-a-php-extension/ , but didn't find any easy way to create the entension when my c++ code may contain several source and header files. Any suggestions please.. – NKS Oct 15 '12 at 06:09
  • 1
    Hi, initially I find the tutorial and the process of creating the php extension a little cumbersome, but once you are on with proper setups and configuration the entire process is easy and worth. Just to highlight one need not to convert the entire C++ code and all libraries to php extension, they can just expose few core methods which can be provided in the extension. – NKS Dec 19 '12 at 05:20