psy/psysh
PsySH is an interactive PHP REPL and runtime developer console for debugging and exploring code. Inspect variables, run snippets, and get contextual help in a powerful shell, with configuration, themes, and integrations available.
Developer Productivity Roadmap:
uopz) to iterate on features faster during development, aligning with modern frontend frameworks’ live-reload capabilities.Build vs. Buy:
php artisan tinker) with a standardized, feature-rich REPL that integrates seamlessly with Laravel’s ecosystem.Key Use Cases:
>>> $user->load('roles')->roles).>>> help, >>> doc User::find()).>>> $this->container->get('auth')).--cwd or Docker exec).Security & Compliance:
.psysh.php files) via Restricted Mode, ensuring alignment with internal security policies.uopz) is a priority for rapid iteration, especially in monolithic applications.tinker) or Symfony, where PsySH’s command-line tools are battle-tested.| Tool | Strengths | Weaknesses |
|---|---|---|
| Laravel Tinker | Native Laravel integration | Limited to Laravel, fewer features |
| PHPStorm Xdebug | GUI-based, breakpoints | Requires IDE setup, slower iteration |
| Composer REPL | Lightweight, no install | Basic functionality, no autocompletion |
| Custom Scripts | Tailored to specific needs | Maintenance burden, no standardization |
*"PsySH is a developer productivity multiplier that cuts debugging time by 30–50% for PHP/Laravel teams. By standardizing an interactive REPL—similar to Python’s ipython or JavaScript’s Node REPL—we eliminate the friction of writing throwaway scripts or guessing at variable states. This directly impacts:
uopz) lets devs test changes instantly without restarting containers or servers.>>> $user->toArray()) instead of wading through logs or documentation.Cost: Free (MIT license), minimal setup. ROI: Measured in dev hours saved—equivalent to hiring 0.5 FTE for a mid-sized team. Let’s pilot it with the backend squad and measure debugging time before/after."*
*"PsySH solves three critical pain points in our PHP stack:
var_dump() chains with a real REPL where you can inspect objects, chain methods, and test logic interactively (e.g., >>> $order->items()->where('status', 'shipped')->count()). Autocompletion and syntax highlighting reduce typos and speed up exploration.artisan tinker is already a PsySH wrapper—this gives us consistency and access to all PsySH features (e.g., hot reloading, clipboard support)..psysh.php files from executing arbitrary code, while the experimental readline (opt-in) offers better UX than ext-readline—no more fighting the shell for multi-line closures or history navigation.Migration Path:
composer require psy/psysh and replace ad-hoc tinker usage with PsySH’s richer feature set.uopz) for teams working on monolithic apps (e.g., legacy codebases).Risks:
*"PsySH turns your terminal into a PHP IDE. Here’s how it’ll change your workflow:
var_dump() Hell: Inspect variables with >>> $user and get pretty-printed output with autocompletion. Chain methods like a pro: >>> $user->posts()->where('published', true)->count().User.php, switch back to PsySH, and your changes are live—no php artisan serve restart. (Requires uopz extension.)$obj-> and see methods/properties in a menu. Fuzzy matching means asum autocompletes to array_sum.>>> $result; copy—no manual echo + Ctrl+C.>>> app() to inspect the container, or >>> route('profile') to debug routes.Get Started:
composer require psy/psysh./vendor/bin/psysh (or php artisan tinker for Laravel).bashrc for instant access:
alias psysh='[ -f vendor/bin/psysh ] && vendor/bin/psysh || php -a'
Slack Emoji: 🚀 (You’ll never go back to var_dump.)"
How can I help you explore Laravel packages today?