{"id":13616497,"url":"https://github.com/phabelio/phabel","last_synced_at":"2026-01-11T16:52:53.795Z","repository":{"id":44136135,"uuid":"293150506","full_name":"phabelio/phabel","owner":"phabelio","description":"PHP transpiler - Write and deploy modern PHP 8 code, today.","archived":false,"fork":false,"pushed_at":"2022-10-08T15:08:51.000Z","size":6299,"stargazers_count":242,"open_issues_count":8,"forks_count":8,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-07-27T21:48:08.874Z","etag":null,"topics":["babel","php","transpiler"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phabelio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"danog"}},"created_at":"2020-09-05T20:36:52.000Z","updated_at":"2024-06-10T18:21:08.000Z","dependencies_parsed_at":"2022-08-12T11:00:52.607Z","dependency_job_id":null,"html_url":"https://github.com/phabelio/phabel","commit_stats":null,"previous_names":[],"tags_count":194,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phabelio%2Fphabel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phabelio%2Fphabel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phabelio%2Fphabel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phabelio%2Fphabel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phabelio","download_url":"https://codeload.github.com/phabelio/phabel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213578671,"owners_count":15608021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","php","transpiler"],"created_at":"2024-08-01T20:01:29.325Z","updated_at":"2026-01-11T16:52:53.790Z","avatar_url":"https://github.com/phabelio.png","language":"PHP","funding_links":["https://github.com/sponsors/danog"],"categories":["PHP"],"sub_categories":[],"readme":"# Phabel [![phabel.io - PHP transpiler](https://phabel.io/badge)](https://phabel.io)\n\n**Write and deploy modern PHP 8 code, today.**\n\nThis 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.\n\nThe 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.\n\nSyntax/feature support:\n* ✅ 8.0+  \n* [async/await syntax](#asyncawait-syntax)\n* Psalm-compatible generics coming soon :D\n\nCreated by [Daniil Gentili](https://daniil.it)\n\n## Usage\n\n```\ncomposer require --dev phabel/phabel\n```\n\nYou can now publish your packagist package, and it will be automatically transpiled to any PHP version supported by phabel.  \n\n**After git tagging a new release, just run**:\n\n```\nvendor/bin/phabel publish\n```\n\n💡 Your PHP 7 users can now install your PHP 8 library 💡  \n💡 **All your dependencies will also be transpiled to the correct PHP version.** 💡\n\n## Supported PHP versions\n\nSyntax/feature support:\n* ✅ 8.0+  \n* [async/await syntax](#asyncawait-syntax)\n\nTarget:\n* ✅ 7.1+  \n* 🐘 5.6, 7.0 in final testing stage.  \n* 💡 5.4, 5.5 support coming soon!  \n\n**No additional commands are required to add support for older versions**: just `composer update` 😄\n\n\n## Examples\n\n### Async/await syntax\n\nPhabel also supports `async/await` syntax, powered by [Amp](https://amphp.org).  \nParallelize your code, using native `async/await` syntax and the [async Amp libraries](https://github.com/amphp) for fully concurrent networking, I/O, database access in pure, native PHP!  \n\n\n#### File I/O\n\nThis example uses the [amphp/file](https://github.com/amphp/file) library:  \n\n```php\n\u003c?php\n\n// Write and read three files on your filesystem, in parallel\n// Async/await syntax powered by phabel.io\n// Concurrency powered by amphp.org\n\nrequire 'vendor/autoload.php';\n\nuse Amp\\Loop;\nuse function Amp\\File\\read;\nuse function Amp\\File\\write;\n\nLoop::run(function () {\n    // This is done in parallel!\n    await [\n        write('file1', 'contents1'),\n        write('file2', 'contents2'),\n        write('file3', 'contents3'),\n    ];\n\n    // This is also done in parallel!\n    var_dump(await [\n        read('file1'),\n        read('file2'),\n        read('file3'),\n    ]);\n});\n```\n\nYou can publish this code as a Composer package and [have it automatically transpile on installation](#usage), or even transpile it manually:  \n```bash\ncomposer require amphp/file phabel/phabel\nvendor/bin/phabel run input.php output.php\nphp output.php\n```\n\n\n## CLI API\n\nWhen you run:  \n```\ncomposer require --dev phabel/phabel\n```\n\nPhabel automatically edits composer.json, adding some configuration parameters, and raising the minimum supported PHP version to `8.0`.  \n\nThen, the following commands are available:\n\n### `publish`\n\nPublishes a transpiled version of your package+dependencies.  \n\n💡 Your PHP 7 users can now install your PHP 8 library 💡  \n💡 **All your dependencies will also be transpiled to the correct PHP version.** 💡\n\nInternally, this command takes the newest (or provided) git tag, and then creates+pushes two subtags:  \n* `tag.9999` - Points to exactly the same commit as `tag`.\n* `tag.9998` - A new commit based on `tag`, with some changes to `composer.json`.\n\nAn example, say you have this `composer.json`:  \n```json\n{\n    \"name\": \"phabel/package\",\n    \"description\": \"An example package.\",\n    \"type\": \"project\",\n    \"require\": {\n        \"php\": \"\u003e=8.0\",\n        \"vendor/new-php8-package\": \"^1\",\n        \"vendor/old-php7-package\": \"^1\"\n    },\n    \"require-dev\": {\n        \"phabel/phabel\": \"^1\"\n    }\n}\n```\n\nNote that `new-php8-package` only supports PHP 8.0+, and `old-php7-package` supports PHP 7.0+.  \n\nHere's what happens when a user requires `phabel/package:^tag` on:\n* PHP 8.0: the unprocessed commit @ `tag.9999` is installed.  \n* PHP 7 (or lower versions): `tag.9998` is loaded, triggering Phabel's composer plugin, which:  \n  * Transpiles `phabel/package` towards PHP 7.\n  * Recursively transpiles `vendor/new-php8-package` and all its dependencies.\n  * Composer still takes care of dependency and requirement resolution, so transpilation only occurs when there is no other choice.  \n  * All dependencies in the `vendor` folder are checked for [covariance and contravariance](https://www.php.net/manual/en/language.oop5.variance.php) conflicts, which are immediately resolved.  \n\n\nNote 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!  \n\n#### Usage:\n```bash\nvendor/bin/phabel publish [options] [--] [\u003csource\u003e]\n```\n\nArguments:\n* `source` - *Optional* source tag name, defaults to the newest tag.\n\nOptions:\n* `-r, --remote[=REMOTE]` - Remote where to push tags, defaults to the upstream of the current branch.\n* `-d, --dry|--no-dry` - Whether to skip pushing tags to any remote.\n\n\n### `run`\n\nThis commands simply transpiles the specified file or directory towards the specified PHP version.   \nThis command is useful for playing around with phabel, or creating a transpiled phar file.  \nAlways make sure to also transpile the `vendor` directory when creating a phar, to automatically resolve [covariance and contravariance](https://www.php.net/manual/en/language.oop5.variance.php) conflicts.  \n\n[`publish`](#publish) is a much simpler version of this command, which automatically transpiles the package (and all dependencies!) upon Composer installation.  \n\n#### Usage:\n\n```bash\nvendor/bin/phabel run [options] [--] \u003cinput\u003e \u003coutput\u003e\n```\n\nArguments:\n* `input` - Input path\n* `output` - Output path\n\nOptions:\n* `--target[=TARGET]` - Target PHP version, defaults to the lowest PHP version supported by Phabel\n* `-i, --install|--no-install` - Whether to install required dependencies automatically\n* `-j, --parallel[=PARALLEL]` - _Experimental:_ Number of threads to use for transpilation, 1 by default\n\n\n## Projects using phabel\n\n[Ping us](https://github.com/phabelio/phabel/issues/new) if you want your project to be added to this list!\n\n* [MadelineProto](https://github.com/danog/MadelineProto)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphabelio%2Fphabel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphabelio%2Fphabel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphabelio%2Fphabel/lists"}