My Photos

www.flickr.com
This is a Flickr badge showing public photos and videos from coogle. Make your own badge here.

Quicksearch

Compiling extensions for Zend Core

Monday, January 7. 2008

Over the past few months there has been an increasing amount of conversation about Zend Core, especially around how best to compile custom extensions for it. While Core does ship with a large list of extensions (which are all QA'd and supported by Zend) there are times when you would like to include non-official extensions from PECL for various reasons. Since there isn't a great deal of documentation out there about how to do this I thought I'd write a quick tutorial.

Basically, to compile an extension for Zend Core you need to go through the following steps:

1) Download the source of your desired extension
2) Create the ./configure script for the extension as a stand-alone shared lib ("PHPize" it)
3) Compile and install the extension
4) Add the extension to your php.ini file

Where most people get caught up is in step two of this process. So, how does one create the correct ./configure script? In a vanilla PHP from php.net, you would do this by executing the phpize command in the extension's source directory:


$ cd /path/to/my/pecl/ext
$/usr/local/bin/phpize


When executed, this shell script will execute the necessary commands to prepare the extension for compilation and create a configure script in the extension's directory which you can then use to compile your extension. Think of this configure script as a mini-version of the standard PHP distribution version which only will work for the specific extension you are building:


$ ./configure --enable-my-ext
$ make
$ sudo make install


When building an extension for Zend Core, the process is almost identical. In fact, the only real difference is that you need to use the Zend Core version of phpize (and perhaps provide some paths to certain files)..for example:


$ cd /path/to/my/pecl/ext
$ /usr/local/Zend/Core/bin/phpize


Because Zend Core is installed it a directory under /usr/local/Zend, chances are when you attempt to execute the ./configure script it will complain that it can't find a program called 'php-config'. To get around this, you'll need to make sure you also include --with-php-config as part of any ./configure command you need to compile the extension:


$ ./configure --enable-my-ext --with-php-config=/usr/local/Zend/Core/bin/php-config
$ make
$ make install


For most cases that should be all you need to compile the extension for Zend Core!

If you need to compile a PDO Driver


One of the few exceptions to the directions above is when you attempt to compile a custom PDO extension. For example, many people are interested in compiling the pdo_sqlite drivers for PDO into Core. Unfortunately, currently such a process is not officially supported by Zend. However, if you feel that you are comfortable enough you can "tweak" Zend Core to allow you to do so by following these steps:

1) Determine the PHP version your version of Zend Core uses by viewing the phpinfo() page of Zend Core.

2) Download the same PHP version from php.net (or check it out from the repository)

$ cvs -d:pserver:cvsread@cvs.php.net:/repository co -r php_5_2_5 php-src

3) Copy all of the PDO header files into Zend Core


$ cd /path/to/php-src/ext/pdo
$ mkdir /usr/local/Zend/Core/includes/ext/pdo
$ cp *.h /usr/local/Zend/Core/includes/ext/pdo


4) Use the procedure outlined above for compiling a custom extension for Core to compile a custom version of the PDO base extension (in the ext/pdo directory of your PHP source install)


$ cd /path/to/php-src/ext/pdo
$ /usr/local/Zend/Core/bin/phpize
$ ./configure --enable-my-ext --with-php-config=/usr/local/Zend/Core/bin/php-config
$ make
$ make install


5) Compile your custom PDO drivers


$ cd /path/to/php-src/ext/pdo_sqlite
$ /usr/local/Zend/Core/bin/phpize
$ ./configure --with-pdo-sqlite --with-php-config=/usr/local/Zend/Core/bin/php-config
$ make
$ make install


Note, when doing this process chances are you will have to compile custom version of all PDO-related extensions for compatibility reasons. Once you have everything compiled you can enable the extensions in PHP by modifying the php.ini file (don't forget to restart the server afterwards!). Assuming everything worked as planned, you should be able to see the extension's information within phpinfo() and the Zend Core GUI will show the extension in the extension list (although you will not be able to control it, etc as you would a standard supported extension).

Hope this helps!

Trackbacks

John Coggeshall's Blog: Compiling extensions for Zend Core
John Coggeshall has blogged about a method he's worked up for ...
Weblog: PHPDeveloper.org
Tracked: Jan 08, 10:56
Chick Here
The resourceful thing to do is to do your probing perfectly.
Weblog: Chick Here
Tracked: Jan 21, 11:51
Weblog: szukaj
Tracked: Feb 14, 22:07
WomenSuits.com Couons | Women Church Dress Suits | Woman Business Suits | Career Suits For Professional Women
Check out some of the most luxurious women's suits, career suits, church suits and speceal occasion wear available on the internet that may be delivered right to your door steps.
Weblog: WomenSuits.com Couons | Women Church Dress Suits | Woman Business Suits | Career
Tracked: Feb 14, 23:15
japanese books store
Sites dealing with j-pop cds resource related material are appreciable.
Weblog: japanese books store
Tracked: Mar 05, 06:47
Weblog: Hip Hop - Rap - Music - Ringtones - Downloads and News
Tracked: Mar 07, 03:17

Comments
Display comments as (Linear | Threaded)

Hay, works for me! Great Stuff!
#1 Alton Crossley (Homepage) on 2008-01-07 20:33 (Reply)
Thanks for this, John. Documentation for building extensions seems to be scarce, and this can be a daunting task for folks not used to building from source all the time.
#2 John Herren (Homepage) on 2008-01-07 23:06 (Reply)
This article makes one wonder why to use Zend Core in the first place..
#3 Evert (Homepage) on 2008-01-08 12:12 (Reply)
Very handy indeed. Just what I was looking for. Thanks a lot! Right, back to Zend :-) !
#4 Adam (Homepage) on 2008-01-09 10:16 (Reply)
Thank you a lot :)
#5 sf (Homepage) on 2008-01-12 18:50 (Reply)

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

 
 

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h04/mnt/28311/domains/blog.coggeshall.org/html/include/plugin_api.inc.php on line 562

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h04/mnt/28311/domains/blog.coggeshall.org/html/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php on line 451

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h04/mnt/28311/domains/blog.coggeshall.org/html/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php on line 476

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h04/mnt/28311/domains/blog.coggeshall.org/html/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php on line 520

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h04/mnt/28311/domains/blog.coggeshall.org/html/plugins/serendipity_event_spamblock/serendipity_event_spamblock.php on line 819

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h04/mnt/28311/domains/blog.coggeshall.org/html/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php on line 316

Deprecated: Assigning the return value of new by reference is deprecated in /nfs/c02/h04/mnt/28311/domains/blog.coggeshall.org/html/plugins/serendipity_event_spartacus/serendipity_event_spartacus.php on line 360