0

unit tests for PECL extensions and how to make them work

Posted by Gabriel on Dec 4, 2009 in pecl, php

Recently I’ve been installing a few PECL extensions, I dev on Snow Leopard which is PHP 5.3 but my colod server is Ubuntu 8.04 LTS which is PHP 5.2, so being me I ignored the various warnings on the sqlite3 page of php.net ( Note: This extension was briefly a PECL extension but that version is only recommended for experimental use. ).
I managed to get the extension installed fine ( phpize, ./configure, sudo make, sudo make install )

wget http://pecl.php.net/get/sqlite3-0.6.tgz
tar xvzf sqlite3-0.6.tgz
cd sqlite3-0.6/
phpize
./configure
sudo make
sudo make install

Now the last line for make install asks you kindly to “Don’t forget to run ‘make test’.”
So let’s do that
Lots of output

Variations on that line appear about 20 times, it seems to be looking in a directory relative to the sqlite3-0.6 directory for the modules
The lovely Cyberspice has made an entry about this already
building php c extensions on ubuntu 9.10
unfortunately I didn’t see this until after I went my own, different route.
Thanks to Derick in #php.pecl on efnet I came up with this bit of code

TEST_PHP_EXECUTABLE=`which php` php /home/gabriel/sqlite3-0.6/run-tests.php /home/gabriel/sqlite3-0.6/tests/*.phpt

which then outputs
Lots of output

So I’d chalk that up as a win, there might be things that get missed running it like this, but I’m not sure.
You can either just run that line of code in the shell or have it in a bash script and then build the bash script to accept parameters so it becomes a lot more customisable.

Tags: , ,

 
0

PHP and PECL Extensions on Snow Leopard

Posted by Gabriel on Nov 15, 2009 in pecl, php, snow leopard

This is a quick post that I could possibly come back and improve later

This is based on something being in a users home dir/sites/ directory.
Although it doesn’t really matter for a cli script
So we have
/Users/gabriel
/Users/gabriel/Sites
/etc/apache2/users/gabriel.conf
is the conf file for the vhost in your user dir which you shouldn’t really have to worry about, but always good to know where it is.

sudo nano /etc/apache2/httpd.conf

uncomment the php line that is found in here, I also uncommented the fastcgi line after it for kicks

sudo apachectl restart

And that’s you sorted for php on apache, note this is php5.3 on apache 2.2.13

For this I’m installing the runkit PECL extension “For all those things you…. probably shouldn’t have been doing anyway….”
We need to install the sex that is xcode, grab the latest one from the Apple Developer Connection website http://developer.apple.com/tools/xcode/

We have svn installed already so grab a copy of it, http://svn.php.net/repository/pecl/runkit/trunk/ is the repo and http://svn.php.net/viewvc/pecl/runkit/trunk/ is the fancy human readable version

svn checkout http://svn.php.net/repository/pecl/runkit/trunk runkit
cd runkit
phpize
./configure
sudo make
sudo make install

and we’re nearly done!
I couldn’t find a default php.ini and a simple phpinfo(); seems to indicate there isn’t one, so we:

sudo cp /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini

find the long list of commented out modules
and add

extension=runkit.so

Quit and save and

sudo apachectl restart

you don’t really need todo that since you’re probably using it in cli but it’s fun to do anyway

Tags: , , ,

Copyright © 2010 Random Rantings of a Demented Mind All rights reserved. Theme by Laptop Geek.