What is Tinker in Laravel?
Answer
Laravel Tinker is a powerful REPL (Read-Eval-Print Loop) for interacting with your Laravel application from the command line. Launch with php artisan tinker. In Tinker, you can run any PHP code with full access to your app: create Eloquent models, test helper functions, run queries, dispatch jobs, and inspect data without writing temporary controllers or routes. Examples: User::factory()->create(), User::where("email", "alice@example.com")->first(), $user = User::find(1); $user->name = "Bob"; $user->save();. Tinker uses the PsySH library and supports tab completion for Laravel classes. It is invaluable for debugging, exploring data, and testing snippets of code during development.
Previous
What is Database Query Builder in Laravel?
Next
What are Eloquent Relationships in Laravel?