PHPackages                             jgswift/recompilr - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jgswift/recompilr

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jgswift/recompilr
=================

runtime class compiler

0.1.1(11y ago)26MITPHPPHP &gt;=5.5

Since Sep 28Pushed 11y ago1 watchersCompare

[ Source](https://github.com/jgswift/recompilr)[ Packagist](https://packagist.org/packages/jgswift/recompilr)[ RSS](/packages/jgswift-recompilr/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

recompilr
=========

[](#recompilr)

PHP 5.5+ factory runtime class compiler

[![Build Status](https://camo.githubusercontent.com/c5f48a4c74579995f86b599d805302d26794ad4572e259109e494d2e44f3c415/68747470733a2f2f7472617669732d63692e6f72672f6a6773776966742f7265636f6d70696c722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/jgswift/recompilr)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/2c22fc6b259f8f392b8bbeb9091e6b9e828ca635b6fdd0f117a38ea13b77a4a5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a6773776966742f7265636f6d70696c722f6261646765732f7175616c6974792d73636f72652e706e673f733d38376134343234323333396232623030376466313664353834376230366330323436353030393331)](https://scrutinizer-ci.com/g/jgswift/recompilr/)[![Latest Stable Version](https://camo.githubusercontent.com/7a358249454ccfbbd6a884d23a9ba60e28e41a93e18d5534501b897ba7f5f841/68747470733a2f2f706f7365722e707567782e6f72672f6a6773776966742f7265636f6d70696c722f762f737461626c652e737667)](https://packagist.org/packages/jgswift/recompilr)[![License](https://camo.githubusercontent.com/fd0c3fe08e12635f34d9e2b61deb3e3e98dbb128755555d4da9c25f17b82f08f/68747470733a2f2f706f7365722e707567782e6f72672f6a6773776966742f7265636f6d70696c722f6c6963656e73652e737667)](https://packagist.org/packages/jgswift/recompilr)[![Coverage Status](https://camo.githubusercontent.com/b884cb3bd6bb557059a8143038e19ac2954c2efff174c5cee386f8f1e0310268/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6a6773776966742f7265636f6d70696c722f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/jgswift/recompilr?branch=master)

Description
-----------

[](#description)

recompilr uses a class definition and recompiles it at runtime using eval and a unique hash identifier. Classes may be recompiled after changes are made to the class definition without requiring the application to restart. This effectively allows an application to redeclare classes at runtime.

Installation
------------

[](#installation)

Install via cli using [composer](https://getcomposer.org/):

```
php composer.phar require jgswift/recompilr:0.1.*
```

Install via composer.json using [composer](https://getcomposer.org/):

```
{
    "require": {
        "jgswift/recompilr": "0.1.*"
    }
}
```

Dependency
----------

[](#dependency)

- php 5.5+
- [adlawson\\veval.php](http://github.com/adlawson/veval.php)

Usage
-----

[](#usage)

### Basic compiling and instantiation

[](#basic-compiling-and-instantiation)

```
// # path/to/FooClass.php
class FooClass {
    /* */
}

// compiles FooClass from given class definition file
recompilr\execute('FooClass','path/to/FooClass.php');

// factory creates an instance of FooClass
$foo = recompilr\make('FooClass');

var_dump($foo); // (object) FooClass_*hash
```

### Compile from autoloaded class

[](#compile-from-autoloaded-class)

```
// class must be available to autoloader
namespace MyNamespace;
class FooClass {
    /* */
}

// compiles FooClass without an explicit class file, relying on the autoloader to find the class definition
recompilr\execute('MyNamespace\FooClass');

// factory creates an instance of FooClass
$foo = recompilr\make('MyNamespace\FooClass');

var_dump($foo); // (object) FooClass_*hash
```

### Recompiling everything

[](#recompiling-everything)

When class definitions are expected to have changed, all classes may be recompiled using `recompilr\all`.

```
// change path/to/FooClass.php while application is running

recompilr\all();
```

*Note: will not compile files where bracketed namespaces are used*

*Note: all compiled classes are final and may not be inherited from*

### Binary handling

[](#binary-handling)

#### Saving to file

[](#saving-to-file)

```
recompilr\execute('MyNamespace\FooClass');

recompilr\binary('path/to/binary.rcx');
```

#### Loading from file

[](#loading-from-file)

```
recompilr\load('path/to/binary.rcx');

$foo = recompilr\make('MyNamespace\FooClass');

var_dump($foo); // (object) FooClass_*hash
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4244d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e60e96f18d8a9dc2aff1363eedbaf210acc96666e7497d2a83d5a416ef397295?d=identicon)[jgswift](/maintainers/jgswift)

---

Top Contributors

[![jgswift](https://avatars.githubusercontent.com/u/661738?v=4)](https://github.com/jgswift "jgswift (6 commits)")

---

Tags

phpfactorycompilerevalmonkey

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jgswift-recompilr/health.svg)

```
[![Health](https://phpackages.com/badges/jgswift-recompilr/health.svg)](https://phpackages.com/packages/jgswift-recompilr)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
