Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time
June 7, 2022 15:22
June 7, 2022 17:11
September 4, 2021 16:39
October 8, 2022 16:39
July 14, 2022 16:36
August 22, 2021 22:19
July 14, 2022 10:18
July 14, 2022 16:36
August 15, 2021 18:55
August 31, 2021 19:10
September 5, 2020 22:37
July 14, 2022 16:36
May 2, 2022 15:32
May 2, 2022 15:32
September 4, 2021 13:10

Phabel - PHP transpiler

Write and deploy modern PHP 8 code, today.

This is a transpiler that allows native usage of PHP 8+ features and especially syntax in projects and libraries, while allowing maintainers to publish a version targeting lower versions of php.

The transpiler seamlessly hooks into composer to transpile the package (and all dependencies down the current branch of the dependency tree!) on installation, on the user's machine, targeting the user's specific PHP version.

Syntax/feature support:

Created by Daniil Gentili


composer require --dev phabel/phabel

You can now publish your packagist package, and it will be automatically transpiled to any PHP version supported by phabel.

After git tagging a new release, just run:

vendor/bin/phabel publish

💡 Your PHP 7 users can now install your PHP 8 library 💡
💡 All your dependencies will also be transpiled to the correct PHP version. 💡

Supported PHP versions

Syntax/feature support:


  • 7.1+
  • 🐘 5.6, 7.0 in final testing stage.
  • 💡 5.4, 5.5 support coming soon!

No additional commands are required to add support for older versions: just composer update 😄


Async/await syntax

Phabel also supports async/await syntax, powered by Amp.
Parallelize your code, using native async/await syntax and the async Amp libraries for fully concurrent networking, I/O, database access in pure, native PHP!

File I/O

This example uses the amphp/file library:


// Write and read three files on your filesystem, in parallel
// Async/await syntax powered by
// Concurrency powered by

require 'vendor/autoload.php';

use Amp\Loop;
use function Amp\File\read;
use function Amp\File\write;

Loop::run(function () {
    // This is done in parallel!
    await [
        write('file1', 'contents1'),
        write('file2', 'contents2'),
        write('file3', 'contents3'),

    // This is also done in parallel!
    var_dump(await [

You can publish this code as a Composer package and have it automatically transpile on installation, or even transpile it manually:

composer require amphp/file phabel/phabel
vendor/bin/phabel run input.php output.php
php output.php


When you run:

composer require --dev phabel/phabel

Phabel automatically edits composer.json, adding some configuration parameters, and raising the minimum supported PHP version to 8.0.

Then, the following commands are available:


Publishes a transpiled version of your package+dependencies.

💡 Your PHP 7 users can now install your PHP 8 library 💡
💡 All your dependencies will also be transpiled to the correct PHP version. 💡

Internally, this command takes the newest (or provided) git tag, and then creates+pushes two subtags:

  • tag.9999 - Points to exactly the same commit as tag.
  • tag.9998 - A new commit based on tag, with some changes to composer.json.

An example, say you have this composer.json:

    "name": "phabel/package",
    "description": "An example package.",
    "type": "project",
    "require": {
        "php": ">=8.0",
        "vendor/new-php8-package": "^1",
        "vendor/old-php7-package": "^1"
    "require-dev": {
        "phabel/phabel": "^1"

Note that new-php8-package only supports PHP 8.0+, and old-php7-package supports PHP 7.0+.

Here's what happens when a user requires phabel/package:^tag on:

  • PHP 8.0: the unprocessed commit @ tag.9999 is installed.
  • PHP 7 (or lower versions): tag.9998 is loaded, triggering Phabel's composer plugin, which:
    • Transpiles phabel/package towards PHP 7.
    • Recursively transpiles vendor/new-php8-package and all its dependencies.
    • Composer still takes care of dependency and requirement resolution, so transpilation only occurs when there is no other choice.
    • All dependencies in the vendor folder are checked for covariance and contravariance conflicts, which are immediately resolved.

Note that as phabel adds support for lower and lower PHP versions, your package will automatically gain support for those versions, too, no need to republish it!


vendor/bin/phabel publish [options] [--] [<source>]


  • source - Optional source tag name, defaults to the newest tag.


  • -r, --remote[=REMOTE] - Remote where to push tags, defaults to the upstream of the current branch.
  • -d, --dry|--no-dry - Whether to skip pushing tags to any remote.


This commands simply transpiles the specified file or directory towards the specified PHP version.
This command is useful for playing around with phabel, or creating a transpiled phar file.
Always make sure to also transpile the vendor directory when creating a phar, to automatically resolve covariance and contravariance conflicts.

publish is a much simpler version of this command, which automatically transpiles the package (and all dependencies!) upon Composer installation.


vendor/bin/phabel run [options] [--] <input> <output>


  • input - Input path
  • output - Output path


  • --target[=TARGET] - Target PHP version, defaults to the lowest PHP version supported by Phabel
  • -i, --install|--no-install - Whether to install required dependencies automatically
  • -j, --parallel[=PARALLEL] - Experimental: Number of threads to use for transpilation, 1 by default

Projects using phabel

Ping us if you want your project to be added to this list!


PHP transpiler - Write and deploy modern PHP 8 code, today.







Sponsor this project



No packages published