Skip to content

Instantly share code, notes, and snippets.

@auroraeosrose
Last active February 2, 2017 14:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save auroraeosrose/0a1447e493cf5bc5fe73574d05a4893c to your computer and use it in GitHub Desktop.
Save auroraeosrose/0a1447e493cf5bc5fe73574d05a4893c to your computer and use it in GitHub Desktop.
PHP Extensions Tutorial
The best way to learn about writing extensions is - to write an
extension! If you want to "code along", you'll need to be set up to
compile PHP 7 extensions, have a checkout of the example code we'll be
using, and have the C library we'll be "wrapping" available on your
system.
All the code we'll be working with is available from
https://github.com/auroraeosrose/php-extensions-code
The library we'll be using is http://uriparser.sourceforge.net/ - it
compiles easily "out of the box" and is available on some systems
packaging
sudo apt-get install liburiparser-dev on ubuntu
You will need a compile environment for your system. That means
autoconf, make, gcc at minimum. You CAN do this on windows, but
setting up a compile environment is much harder (if you're going that
route, hit me up in #phpmentoring on irc.freenode.org and I can walk
you through an installation)
You'll also need a PHP 7 install with headers and phpize - this can
come from a "from scratch" build of PHP or from a binary with dev
packages.
Setting up a compile environment can vary wildly and is highly
dependent on users systems and likes.
If you want to bypass all the hard stuff, and use virtualbox the
recommended way is to just download
https://github.com/rlerdorf/php7dev
which will give you a nicely set up vagrant/virtualbox with everything you need
For those who are more ambitious:
On a mac: https://gist.github.com/denji/8e50fcb13482c5d6c78a
homebrew is recommended to get un-messed up headers and libraries
An install of php7 from the dotdeb or Ondřej Surý's PPA: will work as well
https://www.colinodell.com/blog/2015-12/installing-php-7-0-0
TL;DR
install https://github.com/rlerdorf/php7dev
ssh into it
sudo apt-get install liburiparser-dev
git clone https://github.com/auroraeosrose/php-extensions-code.git
Thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment