PHPackages                             xp-framework/compiler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. xp-framework/compiler

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

xp-framework/compiler
=====================

XP Compiler

v9.11.0(1mo ago)1926.8k↑71.4%[8 issues](https://github.com/xp-framework/compiler/issues)[1 PRs](https://github.com/xp-framework/compiler/pulls)8BSD-3-ClausePHPPHP &gt;=7.4.0CI passing

Since Oct 14Pushed 1w ago1 watchersCompare

[ Source](https://github.com/xp-framework/compiler)[ Packagist](https://packagist.org/packages/xp-framework/compiler)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-framework-compiler/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (12)Versions (139)Used By (8)

XP Compiler
===========

[](#xp-compiler)

[![Build status on GitHub](https://github.com/xp-framework/compiler/workflows/Tests/badge.svg)](https://github.com/xp-framework/compiler/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.4+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_4plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/89a0fc247c88f3c8945cf82e6ffa596f56d8dc5b2cdaebc411aae350e53d04d8/68747470733a2f2f706f7365722e707567782e6f72672f78702d6672616d65776f726b2f636f6d70696c65722f76657273696f6e2e737667)](https://packagist.org/packages/xp-framework/compiler)

Compiles future PHP to today's PHP.

Usage
-----

[](#usage)

After adding the compiler to your project via `composer require xp-framework/compiler`, it will hook into the class loading chain and compile `.php`-files on-demand. This keeps the efficient code-save-reload/rerun development process typical for PHP.

Example
-------

[](#example)

The following code uses Hack language, PHP 8.6, PHP 8.5, PHP 8.4, PHP 8.3, PHP 8.2, 8.1 and 8.0 features but runs on anything &gt;= PHP 7.4. Builtin features from newer PHP versions are translated to work with the currently executing runtime if necessary.

```
