Skip to content

The Zephir Command Line

After installing Zephir, you can use the zephir command to manage the Zephir compiler for your projects. This chapter provides an overview of the command and its various functionalities.

As of Zephir 0.11.7, the compiler uses stderr for displaying error messages, allowing you to handle error outputs separately from normal ones, as shown below:

zephir generate 2> errors.log 1> /dev/null

zephir api

Generates an HTML API based on the classes exposed in the extension

  • --backend=BACKEND: Backend used to generate HTML API (default: ZendEngine3)
  • --path=PATH (or -p PATH): The API theme to be used
  • --output=OUTPUT (or -o OUTPUT): Output directory to generate theme
  • --options=OPTIONS: Theme options
  • --url=URL: The base URL to be used when generating links

zephir build

A meta command that calls the generate, compile, and install commands. Check those commands for more information on supported options and behaviors for each.

zephir clean

Cleans any object files created by the extension

zephir compile

Compile a Zephir extension

  • --backend=BACKEND: Backend used to build extension (default: ZendEngine3)
  • --dev: Build the extension in development mode
  • --no-dev: Build the extension in production mode

Using the --dev option forces building and installing the extension in development mode, including debug symbols and no optimizations. The --no-dev option ensures a production-ready extension, even if the PHP binary was compiled in a debug configuration.

Additionally, options available under extra in the configuration file can be passed here, such as --export-classes and --indent=tabs.

NOTE

Zephir development mode will be enabled silently if your PHP binary was compiled in a debug configuration.

zephir fullclean

Cleans any object files created by the extension (including files generated by phpize)

zephir generate

Generates C code from the Zephir code

  • --backend=BACKEND: Backend used to build extension (default: ZendEngine3)

zephir help

Displays help for a command

zephir init

Initializes a Zephir extension zephir init <namespace>

  • namespace: The extension namespace
  • --backend=BACKEND: Backend used to create extension (default: ZendEngine3)

zephir install

Installs the extension in the extension directory (may require root password)

  • --dev: Install the extension in development mode
  • --no-dev: Install the extension in production mode

zephir list

Lists commands

zephir stubs

Generates stubs that can be used in a PHP IDE

  • --backend=BACKEND: Backend used to generate stubs (default: ZendEngine3)