Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Psysh Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

PsySH is a runtime REPL (Read-Eval-Print Loop) for PHP, designed to provide an interactive debugging and development environment. For a Laravel-based application, it aligns well with:

  • Debugging & Inspection: Enables real-time inspection of Laravel objects (e.g., Eloquent models, request/response cycles, service containers).
  • Prototyping & Testing: Allows quick validation of logic without restarting the application (e.g., testing query builders, middleware, or service methods).
  • Legacy Integration: Works seamlessly with Laravel’s existing tooling (e.g., Tinker, Artisan) and can replace or augment them.
  • Hot Reloading (v0.12.17+): With uopz extension, PsySH can reload modified PHP files dynamically, reducing feedback loops for developers.

Key Laravel Synergies:

  • Service Container Access: Directly inspect and manipulate Laravel’s container (app() helper).
  • Eloquent & Query Builder: Debug raw queries, relationships, and model behavior interactively.
  • Middleware & Request Lifecycle: Inspect $request, $response, and middleware execution in real-time.
  • Artisan Integration: Can be embedded in custom Artisan commands for CLI-driven debugging.

Integration Feasibility

  • Low Friction: PsySH is a Composer package (psy/psysh) with zero Laravel-specific dependencies (beyond PHP 8.1+).
  • Standalone or Embedded:
    • Standalone: Run via CLI (./vendor/bin/psysh) with Laravel’s autoloader.
    • Embedded: Integrate into Laravel’s Artisan (e.g., custom debug:repl command).
  • Configuration: Supports .psysh.php for project-specific tweaks (e.g., aliases, themes, trust settings).
  • Security: Restricted Mode (v0.12.19+) mitigates CWD poisoning risks (critical for shared environments).

Technical Risk

Risk Area Mitigation Strategy
Security Enforce trustProject: 'prompt' in CI/CD; audit .psysh.php files.
Compatibility Test with PHP 8.1+ (Laravel’s LTS range). Symfony Console v7.4+ is supported.
Performance Avoid heavy REPL sessions in production; use --no-pager for CLI scripts.
Hot Reloading Requires uopz extension (not always available); document limitations.
Terminal Dependencies Experimental readline may need terminal-specific tweaks (e.g., SSH, Windows WSL).

Key Questions for TPM

  1. Adoption Strategy:
    • Should PsySH replace Laravel Tinker entirely, or coexist as an advanced alternative?
    • How will it be surfaced to developers (e.g., php artisan psy, IDE integration)?
  2. Security Hardening:
    • Should trustProject default to 'never' in production-like environments?
    • How will .psysh.php files be version-controlled (if at all)?
  3. Performance Tradeoffs:
    • Are there scenarios where PsySH’s overhead (e.g., autoloading, reflection) is prohibitive?
  4. Developer Experience:
    • Should PsySH be pre-configured with Laravel-specific aliases (e.g., $user = User::first())?
    • How will it handle Laravel’s service provider bootstrapping (e.g., bootstrap/app.php)?
  5. CI/CD Impact:
    • Should PsySH be allowed in CI pipelines (risk of accidental interactive sessions)?
    • How will it interact with Laravel’s APP_ENV checks?

Integration Approach

Stack Fit

PsySH is natively compatible with Laravel’s stack:

  • PHP 8.1+: Required for latest features (e.g., experimental readline, hot reloading).
  • Composer: Installs as a dev dependency (require-dev psy/psysh).
  • Symfony Console: Leverages Laravel’s Artisan foundation for CLI integration.
  • Laravel-Specific Enhancements:
    • Service Container: Direct access to app() and bound services.
    • Eloquent: Inspect relationships, query builders, and model events.
    • Request/Response: Debug HTTP lifecycle without HTTP context.

Migration Path

Phase Action Tools/Dependencies
Evaluation Install PsySH in a dev environment; compare with Laravel Tinker. composer require-dev psy/psysh
Basic Integration Add PsySH to composer.json; test standalone usage (./vendor/bin/psysh). bootstrap/app.php (Laravel autoloader)
Artisan Embedding Create a custom Artisan command (e.g., php artisan psy). Illuminate\Console\Command
Configuration Add .psysh.php with Laravel-specific aliases (e.g., $request = app('request')). Psy\Configuration
Advanced Features Enable hot reloading (uopz), experimental readline, or clipboard integration. uopz extension, terminal support
Documentation Update dev docs with PsySH workflows (e.g., debugging middleware). Markdown, IDE snippets

Compatibility

  • Laravel Versions: Tested with Laravel 10+ (Symfony Console v7.4+). Older versions may need psy/psysh:^0.11 (pre-Symfony 7).
  • PHP Extensions:
    • Required: None (except uopz for hot reloading).
    • Recommended: ext-readline or ext-libedit for legacy completion (experimental readline is optional).
  • Terminal Support:
    • Linux/macOS: Full feature support (clipboard, pager, experimental readline).
    • Windows: May require WSL or terminal tweaks (e.g., clipboard commands).
  • IDE Integration:
    • PHPStorm: Use ./vendor/bin/psysh as a "PHP REPL" tool.
    • VSCode: Configure as an external tool with $PSYSH_TRUST_PROJECT=always.

Sequencing

  1. Phase 1: Standalone REPL
    • Install PsySH; test basic Laravel object inspection.
    • Validate .psysh.php trust model in team environments.
  2. Phase 2: Artisan Integration
    • Build a psy:repl command with Laravel’s service container pre-loaded.
    • Example:
      use Psy\Sh;
      use Illuminate\Console\Command;
      
      class PsyCommand extends Command {
          protected $signature = 'psy:repl';
          public function handle() {
              (new Sh)->run();
          }
      }
      
  3. Phase 3: Advanced Features
    • Enable hot reloading (uopz) for rapid iteration.
    • Configure experimental readline for better UX (opt-in).
  4. Phase 4: Documentation & Training
    • Publish cheat sheets for Laravel-specific use cases (e.g., debugging jobs, events).
    • Train team on .psysh.php configuration and security best practices.

Operational Impact

Maintenance

  • Dependency Updates:
    • PsySH releases are frequent (monthly). Pin to a minor version (e.g., ^0.12) to avoid breaking changes.
    • Monitor for Laravel-specific breaking changes (e.g., Symfony Console updates).
  • Configuration Drift:
    • .psysh.php files may proliferate across projects. Enforce a standard template.
    • Use PSYSH_TRUST_PROJECT environment variables for CI/CD consistency.
  • Security Patches:
    • Critical fixes (e.g., CVE-2026-25129) require immediate upgrades. Automate version checks in CI.

Support

  • Common Issues:
    • Trust Prompts: Developers may ignore trustProject warnings. Document how to configure globally.
    • Terminal Quirks: Experimental readline may behave differently across terminals. Provide fallbacks.
    • Hot Reloading: uopz limitations (e.g., no class property changes) require education.
  • Support Channels:
    • Direct users to PsySH’s wiki and Laravel forums.
    • Create a #psysh channel in team Slack for quick troubleshooting.
  • Debugging Workflows:
    • Encourage capturing REPL sessions with >>> (history) and copy (clipboard) for bug reports.

Scaling

  • Performance:
    • Memory: PsySH is lightweight, but long sessions may leak resources. Use --no-pager for scripts.
    • CPU: Reflection-heavy operations (e.g., ls $object) can be slow. Cache frequent inspections.
  • **Team
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope