sebastian/peek-and-poke
sebastian/peek-and-poke is a small PHP utility that uses reflection to peek at and poke into objects. It lets you read and write private and protected properties, making it handy for tests that need to inspect or set up object state without changing production code.
ReflectionClass/ReflectionMethod — roughly a few dozen lines. The real decision is whether to carry a third-party dev dependency or own a small internal test helper.require-dev concern and should never appear in production dependency graphs.Consider it when:
require-dev, the PHP version is compatible, and you accept an unmaintained artifact.Look elsewhere — or copy the pattern — when:
NOASSERTION. For a 36-star archived package with zero dependents, the legal review cost exceeds the value of the code; this alone typically blocks adoption in enterprise environments.ReflectionClass usage in tests, or — preferably — a design change (extract collaborators, introduce interfaces, or expose @internal accessors for tests). If you are testing private methods heavily, the higher-leverage answer is usually refactoring, not tooling.To executives: This is a tiny, test-only PHP utility — not a platform bet. It has no runtime footprint and no product impact. Because it is archived and carries an unclear license, my recommendation is not to adopt it as a dependency; the capability is small enough to replicate internally in under an hour, eliminating the maintenance and legal overhead entirely.
To engineering: It is a reflection wrapper that grants tests access to private state and methods. Useful as a temporary bridge during legacy modernization, but the same behaviour is a few dozen lines over ReflectionClass. Vendor a small internal helper instead: same capability, our license, our maintenance, and no unmaintained transitive dependency. If you find yourself using it more than occasionally, treat that as a signal to invest in test seams and encapsulation rather than in the tool.
How can I help you explore Laravel packages today?