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

Tinker Laravel Package

laravel/tinker

Laravel Tinker provides an interactive REPL for Laravel, letting you run PHP code and interact with your application from the command line via Artisan tinker. Great for debugging, testing ideas, and exploring models, services, and configuration.

View on GitHub
Deep Wiki
Context7

Laravel Tinker is a powerful REPL for the Laravel framework, giving you an interactive shell to execute PHP code within your application context. It’s ideal for quickly exploring models, testing queries, and debugging behavior without creating routes, controllers, or temporary scripts.

Run it via Artisan and experiment safely in a familiar workflow to prototype ideas, inspect services, and validate logic in real time.

  • Interactive Artisan tinker console for your Laravel app
  • Access Eloquent models, facades, and the service container instantly
  • Rapidly test database queries and application logic
  • Useful for debugging and quick experimentation
  • Streamlines prototyping without changing your codebase
Frequently asked questions about Tinker
How do I install Laravel Tinker in my Laravel project?
Run `composer require laravel/tinker` in your project root. No additional configuration is needed—just use `php artisan tinker` to start the REPL. It integrates seamlessly with Laravel’s Artisan CLI.
Can I use Laravel Tinker with Laravel 13 or the latest version?
Yes, Tinker supports Laravel 13+ with version 3.x, which requires PHP 8.1+. Check the [Laravel documentation](https://laravel.com/docs/artisan#tinker) for version-specific details and compatibility.
What’s the difference between `php artisan tinker` and `php artisan tinker --execute`?
The `--execute` flag runs a single command and exits immediately, ideal for quick one-liners like `php artisan tinker --execute='User::all()'`. Without it, you enter an interactive REPL session for deeper exploration.
How do I debug Eloquent models or database queries in Tinker?
Tinker automatically casts Eloquent models for readable output. Run queries like `User::where('active', true)->get()` and inspect results interactively. Use `dd()` or `dump()` for detailed debugging.
Is Laravel Tinker safe to use in production environments?
No, Tinker is **not** designed for production. It exposes the Laravel service container and database interactively, which is a security risk. Restrict access via `APP_ENV` checks or middleware in production.
How can I customize Tinker’s output or add custom casters?
Extend Tinker’s behavior by defining custom casters in your `AppServiceProvider`. Use `Tinker::casts()` to format domain-specific types (e.g., `Carbon` instances or custom collections).
Why do I see PsySH trust prompts when using Tinker, and how do I disable them?
PsySH (the underlying REPL) prompts for trust if files change. Disable it globally by setting `PSYSH_TRUST_PROJECTS=1` in your environment or use `Tinker::avoidTrustPrompts()` in a service provider.
Can I use Laravel Tinker to test Laravel queues or jobs interactively?
Yes! Dispatch jobs directly in Tinker (e.g., `dispatch(new ProcessPodcast))` and inspect their state. It’s perfect for debugging job logic without writing full test scripts.
Are there alternatives to Laravel Tinker for debugging?
For Laravel, alternatives include **Laravel Debugbar** (browser-based debugging) or **PHP’s built-in CLI** with manual `require` calls. However, Tinker is uniquely optimized for Laravel’s ecosystem with Eloquent casting and service container access.
How do I integrate Tinker into CI/CD pipelines or test environments?
Tinker is primarily a dev tool, but you can enable it in CI for debugging by checking `APP_ENV` or `DEBUG` flags. Use `--execute` for one-off commands in scripts (e.g., `php artisan tinker --execute='Test::run()'`).
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport