PHPackages                             linusshops/self-modifying-code - 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. linusshops/self-modifying-code

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

linusshops/self-modifying-code
==============================

Runtime modification of class definitions

0.0.3(9y ago)016[1 issues](https://github.com/linusshops/self-modifying-code/issues)MITPHPPHP ^5.0.0

Since Dec 11Pushed 9y ago1 watchersCompare

[ Source](https://github.com/linusshops/self-modifying-code)[ Packagist](https://packagist.org/packages/linusshops/self-modifying-code)[ Docs](https://github.com/linusshops/self-modifying-code)[ RSS](/packages/linusshops-self-modifying-code/feed)WikiDiscussions master Synced today

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Self Modifying Code (SMC)
=========================

[](#self-modifying-code-smc)

[![Build Status](https://camo.githubusercontent.com/f0a8ca193263b81e32a74b88588aedd60541d32b8fd6b681125af36b76d9262f/68747470733a2f2f7472617669732d63692e6f72672f6c696e757373686f70732f73656c662d6d6f64696679696e672d636f64652e737667)](https://travis-ci.org/linusshops/self-modifying-code)

Requires [Runkit](http://php.net/manual/en/book.runkit.php) and [Reflection](http://php.net/manual/en/book.reflection.php)

SMC provides a convenient way to reload functionality while you are in a REPL or debug console.

Ever test something in the console, and realize while you're debugging what needs to be changed? Normally, you'd have to terminate the session, losing any accumulated context from your console session. SMC allows you to reload a class or method definition in mid-execution (similar to REPL environments provided by lisp and clojure).

Due to a limitation in runkit, if you are currently executing a class, you cannot reload the whole thing. However, you can reload individual methods as well.

🔥🔥🔥🔥🔥🔥

This is ONLY intended to be used as a debugging aid or in a REPL environment.

If you are using this to implement functionality, you need to seriously re-evaluate your decisions.

🔥🔥🔥🔥🔥🔥

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

[](#installation)

If runkit is not installed, install it with `pecl install runkit`.

Add `linusshops/self-modifying-code` to your composer.json.

Usage
-----

[](#usage)

All reload methods return a boolean indicating if SMC was able to redefine the requested identifier.

All reload methods are able to accept either a string class definition, or an instance of the class itself.

### Reload a class

[](#reload-a-class)

```
SMC::reload_class('SomeClassName')

```

### Reload a class method

[](#reload-a-class-method)

```
SMC::reload_method('SomeClassName', 'methodName')

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~258 days

Total

3

Last Release

3338d ago

PHP version history (2 changes)0.0.1PHP &gt;=5.0.0

0.0.3PHP ^5.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8fa6044a587e4dd9355bd68d6c3a31c628cc26752e600c81074e0049ec383688?d=identicon)[linusshops](/maintainers/linusshops)

---

Top Contributors

[![dersam](https://avatars.githubusercontent.com/u/475851?v=4)](https://github.com/dersam "dersam (26 commits)")

---

Tags

debugginglinus shopsmx canadacanadas motorcycle

### Embed Badge

![Health badge](/badges/linusshops-self-modifying-code/health.svg)

```
[![Health](https://phpackages.com/badges/linusshops-self-modifying-code/health.svg)](https://phpackages.com/packages/linusshops-self-modifying-code)
```

###  Alternatives

[sashas/bug-from-email

A Magento 2 module for issue #14952

3537.0k](/packages/sashas-bug-from-email)

PHPackages © 2026

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