leovie/php-method-runner
A lightweight PHP utility that lets you run methods on objects by name, making it easy to invoke dynamic or configurable method calls without verbose reflection code. Ideal for small Laravel or standalone PHP projects.
ReflectionMethod + eval plumbing. It directly supports a build-vs-buy decision: "ship a rules engine this sprint" vs. "buy a workflow vendor."Method object executed on demand — useful as a per-tenant customization layer without a microservice per tenant.echo/print corrupting JSON bodies or headers.Roadmap caveat: this is an enabler, not a product differentiator. It shortens the time-to-first-version of the features above by days, not months; do not let a dependency this thin shape the roadmap itself.
Consider adopting when:
Method/source string from your own codebase or a trusted store, not arbitrary user input.Look elsewhere when:
symfony/process, Docker, gVisor/Firecracker, Wasm) or a purpose-built sandbox. Running user code with access to your app's classes, env, and filesystem is a breach waiting to happen.echo/print surfacing, wrap those methods, use an output buffer around the call, or return values instead. Treat this as a behavior change to verify on upgrade, not a cosmetic patch.nikic/php-parser + a custom interpreter, or a hosted execution service.v3.0.x line, but a single output-suppression patch is a pulse, not a maintenance commitment; ecosystem adoption remains effectively nil (no meaningful dependents). If it's on a critical path, plan to fork and own it, and verify PHP-version compatibility and test coverage before committing.Executive summary. leovie/php-method-runner is a small, free, permissively licensed (BSD-3) PHP utility that lets our application execute the source of a PHP method at runtime. It is an accelerator, not a platform: it can shorten delivery of configurable business rules, tenant customizations, and internal code tooling by removing boilerplate. The latest patch (v3.0.1) suppresses method output, which makes it safer to drop into request paths, but it remains not a security sandbox (output is muted, side effects are not) and the project is thinly maintained (a small patch series, negligible ecosystem adoption). Recommendation: use it for internal, trusted-input scenarios and vendor/fork it so we own the code; if we ever expose code execution to customers, budget separately for real isolation. The cost of adoption is near zero; the cost of misuse is a security incident, so scope it deliberately.
For engineering. It eliminates the ReflectionMethod + scoped-eval plumbing needed to run a method body with controlled $this/arguments. Good fit for: rule engines over vetted snippets, code playgrounds, characterization tests during refactors, and generation-verification in CI. Upgrade note for v3.0.1: method output is now suppressed — audit any caller that consumed printed output and adapt it (output buffering around the call, or return values) before bumping the pin. Constraints still ours to solve: no process isolation, no timeouts or resource limits, no typed argument or return validation, and no protection against side effects (I/O, state mutation). Dependency risk remains real (one maintainer, negligible dependents); pin the version, add a smoke test matrix across our supported PHP versions, and be ready to maintain a fork. Prefer it where a failure is a bug, not a breach — and never where the input is untrusted.
How can I help you explore Laravel packages today?