psy/psysh
PsySH is an interactive PHP REPL, runtime developer console, and debugger. Explore code, inspect variables, and run commands in a powerful shell with history, configuration, themes, and integrations—ideal for fast debugging and experimentation.
PsySH is a runtime REPL (Read-Eval-Print Loop) for PHP, designed to enhance developer productivity by providing an interactive debugging and exploration environment. For a Laravel-based application, it fits well as a complementary tool to Laravel Tinker (which is built on PsySH). Key alignment points:
ls, doc, show) aligns with Laravel’s introspection needs (e.g., inspecting routes, queues, or cached data).php artisan psysh). No major architectural changes are required..psysh.php) and CLI flags, allowing customization for CI/CD or production-like environments (e.g., --no-pager for scripts).trustProject) to mitigate risks from untrusted directories. Requires explicit trust management in CI/CD pipelines.uopz) may introduce instability. These should be opt-in and tested in staging.useExperimentalReadline in CI).trustProject default to never in CI, with manual overrides for trusted repos?php -a. Justify PsySH’s added value (e.g., better autocompletion, clipboard support).php artisan tinker) or extend it via custom artisan commands.ext-readline or ext-libedit for traditional readline (or use PsySH’s experimental pure-PHP readline for cross-platform consistency).composer global require psy/psysh) or locally (composer require --dev psy/psysh)..psysh.php config to customize:
return [
'useExperimentalReadline' => true, // Opt-in for new features
'trustProject' => 'prompt', // Security best practice
'clipboardCommand' => 'pbcopy', // macOS clipboard support
];
php artisan tinker with php artisan psysh for feature parity.composer.json scripts for CI/CD debugging:
"scripts": {
"debug": "psysh"
}
route:list, queue:work --psysh) using PsySH’s command system.$app->make('auth')).route(), view()) and facades (e.g., Cache::remember()).--cwd to run PsySH in the Laravel root, ensuring autoloading and config paths are correct..env or via APP_ENV checks).composer.json and test in staging..psysh.php for team-specific settings (e.g., themes, clipboard).- name: Debug on failure
if: failure()
run: psysh --no-pager --trust-project=always
if (app()->environment('production')) {
throw new RuntimeException('PsySH disabled in production.');
}
psy/psysh to a specific version in composer.json for stability..psysh.php files for malicious config (e.g., eval or shell_exec).help, doc, show) in the team’s debugging guide.$_, $_SERVER, $app) for Laravel-specific use cases.--experimental-readline for cross-platform support.composer dump-autoload is run post-install.trustProject settings and directory permissions.PSYSH_LOG=1 psysh --no-pager > psysh-debug.log
useExperimentalReadline in CI.--no-pager for scripted usage.uopz) increases memory usage. Disable in production-like environments.| Scenario | Risk | Mitigation |
|---|---|---|
Malicious .psysh.php |
Code execution (CVE-2026-25129) | Set trustProject: never in CI, audit configs. |
Infinite recursion in eval |
Crash or memory exhaustion | Use --no-eval flag or restrict eval. |
| Corrupted history file | Lost commands | Backup ~/.psysh_history or use SQLite history. |
| PHP extension conflicts | uopz or readline issues |
Test with php -m to check loaded extensions. |
| Terminal compatibility | Broken UI in SSH/WSL | Use --experimental-readline for consistency. |
ls App\Models, doc User).$user = User::first(); $user->load('posts')).var_dump, dd, and `How can I help you explore Laravel packages today?