spatie/laravel-artisan-dd
Run one-off Laravel code from the command line without opening Tinker. Use php artisan dd "User::first()" to execute expressions and dump results. Supports multiple expressions and short class names for quick debugging and inspection.
dd) without modifying core Laravel workflows, making it ideal for debugging-focused applications. It aligns with Laravel’s CLI-first philosophy and complements existing tools like Tinker.composer require and a single command registration (handled automatically). No configuration files or service providers needed.--depth or --max-items flags (suggested enhancement).local environments only (no production exposure).php artisan invocation (unlike direct HTTP requests).dd output may terminate the CLI process. Wrap command in a try-catch or log errors to a file.--timeout parameter (e.g., 5 seconds).php -a, or IDE debuggers) in your team’s workflow?php artisan, laravel-sail, forge). Works alongside:
dd() helper).composer require --dev spatie/laravel-artisan-dd.php artisan dd "App\Models\User::count()").var_dump).dd instead of Tinker for one-liners").dd in scripts).alias dd='[ -f artisan ] && php artisan dd' in .bashrc).dd command doesn’t clash with existing namespaces.php artisan --version works).composer require spatie/laravel-artisan-dd.php artisan dd "1 + 1" → Should output 2.php artisan dd "User::first()->toArray()".php artisan dd "User::with('posts')->first()" (test recursion limits).dd "Auth::user()->roles").php artisan dd --help) to identify adoption gaps.dd() is deprecated, the package may need adjustments).composer dump-autoload ran post-install.try-catch in code being debugged).--depth or break queries into chunks.--limit (e.g., php artisan dd "User::limit(10)->get()").User::where('active', true)->dd()).| Failure Scenario | Impact | Mitigation |
|---|---|---|
Uncaught exception in dd |
CLI process crashes | Wrap command in try-catch or log to file. |
| Recursive data (e.g., models) | Memory exhaustion | Add --depth flag or use toArray(). |
| Sensitive data exposure | Security risk | Restrict to local/dev environments. |
| Laravel version mismatch | Command fails | Pin version in composer.json. |
| CLI timeout | Hangs on long queries | Set PHP’s max_execution_time or add timeout. |
dd replaces:
var_dump/print_r for structured output.php artisan dd "Test::failed()->first()->output").composer.json scripts (e.g., post-install-cmd to log dd invocations).dd’s speed for simple queries.How can I help you explore Laravel packages today?