Categories


Archives


Recent Posts


Categories


A Few Notes on Zephir

astorm

Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Zephir is a programming language for building PHP extensions. As in, the .so files that extend the PHP language itself. Normally you need to use the C programming language to create a PHP extension, but Zephir is an intermediate language you can compile down to C code, (using the provided tooling). Its build system also automatically stitches everything together into a compilable/phpize-able extension. i.e. you say

zephir build

and you have a working extension.

The docs are pretty good, although I ran into a few unmentioned gotchas while getting the hello world example up and running.

  1. You’ll need to install their PHP parse extension to get a working build system. (Zephir appears to use PHP itself as part of its build pipeline)

  2. They don’t appear to officially support Mac OS, so I had to use hombrew to get a copy of re2c on my system.

  3. Similarly, when I built the parser, my computer yelled at me: ./install: line 182: aclocal: command not found, but things seemed to compile without issue. I suspect there’s other rough edges related to Mac OS support

  4. I am a derp

The idea of “modern” PHP extension development is a bit of an oxymoron, but Zephir’s is the best system I’ve found so far.

Copyright © Alan Storm 1975 – 2018 All Rights Reserved

Originally Posted: 30th July 2018