LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-22-2010, 12:28 AM   #1
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
How to write a php extension?


I've spent quite a bit of time tinkering with the amfext extension. This extension sort of works but doesn't properly handle AMF3 properly (the latest spec from adobe). I've written some AMF3 serialization routines in PHP so I know the routine pretty well. I'm thinking I can really help this extension. The amf website says that as of 2 years ago they are looking for a new maintainer. I think I could do it.

The code is written in C. I'm really rusty, but this is precisely the kind of project I've been looking for to refresh my C skills. I was hoping to find out a few things though.

1- Is there an official training course, tutorial, or documentation for making php extensions?
I found this one and this one but I have no idea how old of 'official' they might be.

2- Is there a user community devoted to making PHP extensions where I can get help?
Linuxquestions.org and PHPBuilder.com have been indispensable in helping me learn the ins and outs of a LAMP stack. I need something like that for writing a PHP extension -- if such a thing exists.

3- Is there some kind of IDE setup or environment I can set up to debug this code?
I've worked with Eclipse and X-code a bit but they seem to lean pretty heavily toward a project paradigm. The AMFEXT code relies on all kinds of header files in the PHP source, the phpize command, a configure script, and creates a shared library (amf.so). Since it's not a stand-alone application, I find myself wondering how in the world I'm supposed to run it, debug it, test, it, etc.

Any feedback at all would be much appreciated.
 
Old 07-22-2010, 04:32 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

The links you posted seem quite old. There is quite a bit of difference between Zend engine 1 and Zend engine 2 (PHP 4 and 5).

The manual has more up to date information:

http://www.php.net/manual/en/internals2.php
 
Old 07-22-2010, 10:17 PM   #3
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Original Poster
Rep: Reputation: 78
Thanks for that link. It looks a bit more concise--if a bit less user-friendly--than those other older articles. I think these will be enough to get me started.

Still wondering about items 2 and 3. Is there a community dedicated to PHP extension development? How would one test one's extension.

Setting a proper environment for development seems a bit tricky. The process to build an extension involves a phpize program -- not sure exactly what that does. And then there's a configure script which builds an elaborate makefile depending on the locations of one's PHP source code all over the place. The cc command and all its include dir options is quite elaborate. I'm having a hard time understanding how I might set up Eclipse as my IDE in this situation. I'd hate to have to code in nano or notepad and type "phpize/configure/make/install" every single time I want to test it. Forgive me if there's some obvious way to set this sort of thing up -- it's been a very long time since I've written code in C.

I do think that for testing one might use the php dl function of PHP to dynamically load the compiled library.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Write a Firefox extension to rotate images in mapping apps LXer Syndicated Linux News 0 10-17-2008 08:10 PM
php and mycrypt extension Carpo Slackware 11 04-24-2008 11:45 AM
How to install php extension? strangevarius SUSE / openSUSE 0 04-11-2007 06:17 AM
How write linux make file for php extension Janehe Programming 0 08-23-2006 03:32 PM
Build PHP extension. ugenn Linux - Software 1 11-05-2003 05:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration