Before beginning this tutorial, you'll need a development environment with the following packages:
- Compiler:
gccandclangare both excellent choices. - Build tools:
autoconf,automake,libtool - (Optional) parser generators:
re2candbison - PHP 7.x with development headers:
- Either distro packages such as:
php7andphp7-devel - PHP compiled from source and installed with
sudo make install. If compiling from source, then the--enable-debugswitch is recommended, as well as the optional re2c and bison packages.
- Either distro packages such as:
libcurland development headers: As part of this tutorial, we'll eventually be linking against libcurl. Install the library and it's associated development headers from your distro or install from source.
Obviously, you'll want this repo checked out in your build environment as well.
Be sure to git pull to make sure you have the most recent version.
This tutorial is split into steps, with one commit per step. At each commit, you should be able to compile the extension code as-provided using the following steps:
$ phpize
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718$ ./configure
checking ...
checking ...
checking ...
[ lots of output ]
configure: creating ./config.status
config.status: creating config.h$ make
/bin/bash .../libtool --mode=compile cc -I. -DPHP_ATOM_INC -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -DHAVE_CONFIG_H -g -O0 -c tutorial.c modules/tutorial.so
----------------------------------------------------------------------
Libraries have been installed in:
.../modules
Build complete.
Don't forget to run 'make test'.$ php -d extension=modules/tutorial.so --re tutorial
Extension [ <persistent> extension #40 tutorial version <no_version> ] {
}