php-config
--extension-dir. "Piece of cake", I thought.extension=php_ming.so. I tried the
sample code (you'll find it later in this article) -- it didn't
work. My intuition told me that it might be because I was using
Debian along with the stable packages I apt-got (... err...
apt-get in past tense) install. Well, I was right. So, let's
discuss about how to do it in Debian.make
static. This produced $MINGINST/libming.a and
some object files under $MINGINST/src. Next, still
following the README, I changed directory to
$MINGINST/php_ext and typed make.
Whew... lots of errors. I read the error messages and they were
about header files being not found. Maybe you think that it
shouldn't be a problem if we have apt-got (err... perfect form
of apt-get...) install php4-dev (for your
information, I'm using the stable version). The fact is: it is,
and it is because of the Debian directory layout that
"confuses" php-config --includes being used inside
Makefile. The same thing also applies for
php-config --extension-dir.With such a condition, in such a "quick and dirty" way, I modified Makefile so it became like this: (includes wrapped for formatting for this example)
prefix=`php-config --prefix`
includes=-I /usr/include/php4/main -I /usr/include/php4/Zend \
-I /usr/include/php4/ext/standard -I /usr/include/php4 \
-I /usr/include/php4/TSRM
extension=/usr/lib/php4/apache
DEFINES = -DHAVE_MING -DCOMPILE_DL_MING -DZEND_NEW_ERROR_HANDLING
CFILES = ming.c
php_ming.so: ming.o
${CC} -shared -fpic ming.o ../libming.a -o php_ming.so -lm
ming.o: ${CFILES}
${CC} ${DEFINES} -c ming.c -I. -I.. ${includes}
clean:
rm -f php_ming.so
install:
cp php_ming.so ${extension}
echo "Don't forget to add 'extension=php_ming.so' to php.ini!"
make and
make install successfully. As the message
make install says, we should not forget to add
extension=php_ming.so to php.ini (and
something not mentioned, restart our web server). I did those
things and I could later use the code shown in the next
section.
<?php
// create movie and set parameters
$movie=new SWFMovie();
$movie->setBackground(0xee,0xee,0xff); // nice light blue
$movie->setDimension(800,600);
// draw rectangles
for($c=0;$c<5;$c++)
{ $shape=new SWFShape();
// set line width 20, with blue shade
$shape->setLine(20,0x00,0x00,$c*50);
$offset=$c*20;
$shape->movePenTo(100+$offset,100+$offset);
$shape->drawLineTo(700-$offset,100+$offset);
$shape->drawLineTo(700-$offset,500-$offset);
$shape->drawLineTo(100+$offset,500-$offset);
$shape->drawLineTo(100+$offset,100+$offset);
// add to canvas
$movie->add($shape);
}
// send output
header("Content-Type:application/x-shockwave-flash");
$movie->output();
?>
When not playing the music, Iman S. H. Suyoto probably plays around with software development tools. He currently works as a trainer for web development technologies in World Wide Web Institute Indonesia. He has published several articles in MIKRODATA, an Indonesian computer and programming publication. In 1997, he started doing web development. He has been using PHP since 2000.