ramsey/composer-repl-lib
Library for building interactive Composer-powered PHP REPLs. Provides the core loop and helpers to evaluate code in a Composer project context, load autoloaded classes, and inspect results—useful for CLI shells, debugging tools, and developer consoles.
Start by installing ramsey/composer-repl-lib via Composer in your tool or plugin:
composer require ramsey/composer-repl-lib
Then, instantiate the REPL builder in your command logic (e.g., inside a Symfony Console or Laravel command):
use Ramsey\Composer\Repl\ReplBuilder;
$repl = (new ReplBuilder())
->withBootstrapFile('vendor/autoload.php')
->build();
$repl->start();
The first use case is typically spinning up a REPL inside a custom CLI command to inspect Composer-installed dependencies, test autoloaded classes, or debug configLoading logic interactively.
Command::handle() method to offer developers a live environment without spawning a full shell.withVariable('name', $value) to inject application state (e.g., $app, config, or factory instances) into the REPL scope.EvaluatorInterface to tailor eval behavior (e.g., scope isolation, result formatting).php artisan my:repl command.->withBootstrapCode('$_env = $_ENV;')) to expose dynamic runtime state safely.eval()-untrusted input—this library is for developer tooling, not production use.vendor/autoload.php is included before the REPL starts—withBootstrapFile() assumes PSR-4/autoloading is ready.php_sapi_name() === 'cli'; some REPL internals (e.g., readline) may silently fall back to basic input.null for non-echoing expressions—use var_dump() or echo explicitly to inspect results.Evaluator to add macro functions or hook into debug output (e.g., add Xdebug-style tracing).start() invocation creates a fresh scope—store reusable snippets in ~/.composer-repl/config.php or your custom bootstrap.How can I help you explore Laravel packages today?