Skip to content
This repository has been archived by the owner on Apr 30, 2022. It is now read-only.

linusshops/self-modifying-code

master
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?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Self Modifying Code (SMC)

Build Status

Requires Runkit and Reflection

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

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

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

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

SMC::reload_class('SomeClassName')

Reload a class method

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

About

Wrapper for runkit to allow modifying class definitions during runtime

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages