To install Zephir, please follow these steps:


To build a PHP extension and use Zephir you need the following requirements:

  • Zephir parser >= 1.3.0
  • A C compiler such as gcc >= 4.4 or an alternative such as clang >= 3.0, Visual C++ >= 11 or Intel C++. It is recommended to use gcc 4.4 or later
  • re2c 0.13.6 or later
  • PHP development headers and tools

For Linux based systems you’ll need also:

  • GNU make 3.81 or later
  • autoconf 2.31 or later
  • automake 1.14 or later
  • libpcre3
  • The build-essential package when using gcc on Ubuntu (and likely in other distributions as well)

If you’re using Ubuntu, you can install the required packages this way:

sudo apt-get update
sudo apt-get install git gcc make re2c php php-json php-dev libpcre3-dev build-essential

Please note that specific versions of libraries and programs at the time of reading this guide may vary.

Since Zephir is written in PHP, you need to have a recent version of PHP installed, and it must be available in your console:

php -v
PHP 7.3.7 (cli) (built: Jul 14 2019 17:24:22) ( ZTS DEBUG )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.7, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.7, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans

Also, make sure you have the PHP development libraries installed along with your PHP installation:

phpize -v
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731

You don’t have to necessarily see the exact above output, but it’s important that these commands are available to start developing with Zephir.

Installing Zephir

First make sure that the Zephir parser extension is installed and activated. You can find installation instructions in the Zephir Parser repository.

Release PHAR

The recommended, officially supported, and easiest-to-use way to install Zephir is to simply grab the latest release PHAR from GitHub, and download/move it to somewhere in your $PATH. (You’ll probably also want to rename it to drop the .phar extension, so you can run it as zephir instead of zephir.phar.)


The PHAR isn’t available before 0.11.4, so if you need an older version, you can use Composer, in one of two ways:

Global Composer Application

composer global require phalcon/zephir

There are two approaches to running Zephir at this point. The first is to ensure that ${COMPOSER_HOME}/vendor/bin is in your $PATH, then Zephir should be available as zephir on the command line. The second is to simply use composer global exec zephir instead.

Project Dependency

composer require phalcon/zephir

Use composer exec zephir within the project you installed Zephir in, above, to run it. (Alternately, you can still run vendor/bin/zephir.)

Git Clone

Finally, you can also simply clone the latest tag from GitHub, install the dependencies, and run Zephir from there:

git clone --depth 1 -b $(git ls-remote 0.12.* | sort -t/ -k3 -Vr | head -n1 | awk -F/ '{ print $NF }')
composer install

You’ll need to either use the path to zephir/zephir, or create a symlink in a directory in your $PATH, to run Zephir using this option.

Testing the Installation

Check if Zephir is available from any directory by executing:

zephir help