Using external library from PHP?

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
DarkSun24
Forum Newbie
Posts: 3
Joined: Sat Feb 03, 2007 8:39 am

Using external library from PHP?

Post by DarkSun24 »

Hey there,

I have a simple PHP script that gets an HTTP REQUEST and fetch it's content.
Now I want to do lot's of processing to this content, and I already have a C/C++ Library that does it, so I would rather avoid writing the same code in PHP.

Is there a way of using an external C library from PHP?

Many thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What kind of library is it? I'm referring to the file itself, like a .lib, executable..

What sort of processing does it do?
DarkSun24
Forum Newbie
Posts: 3
Joined: Sat Feb 03, 2007 8:39 am

Lib

Post by DarkSun24 »

Lib file, written in C.
It processes the received request buffer and generated a reply http buffer according to the request parameters + some library internal data.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If memory serves, lib files must be compiled into an executable file such as a dll/so/exe. If you truly wish to not implement it in PHP (the most portable form) you will therefore need to build an extension around the lib (not so portable.)
DarkSun24
Forum Newbie
Posts: 3
Joined: Sat Feb 03, 2007 8:39 am

Lib

Post by DarkSun24 »

And suppose I make the LIB an SO, can I use it from PHP? how?

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's not as simple as making a .so, but interconnecting the functionality with PHP registered functionality that the extension adds.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Take a look at http://devzone.zend.com/node/view/id/1021

But
It processes the received request buffer and generated a reply http buffer
doesn't sound like you need a php extension but an apache/iis/webserver module.
Post Reply