explaingit

laravel/tinker

7,431PHPAudience · developerComplexity · 1/5LicenseSetup · easy

TLDR

An interactive PHP console built into every Laravel project that lets you query your database, test code, and run commands directly against your running application from the terminal without writing a script.

Mindmap

mindmap
  root((tinker))
    What it does
      Interactive PHP console
      Live app access
      REPL for Laravel
    Capabilities
      Query database models
      Create test records
      Call any app function
    Built on
      PsySH shell
      Laravel artisan CLI
    Audience
      Laravel developers
      PHP developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Query your Laravel database models interactively from the terminal to inspect live data without writing a route or controller

USE CASE 2

Create test records or run one-off scripts against your Laravel application during development without a browser

USE CASE 3

Test a specific service method or piece of business logic in your Laravel app immediately without setting up a test file

Tech stack

PHPLaravelPsySH

Getting it running

Difficulty · easy Time to first run · 5min

Included by default in every new Laravel project, start it with php artisan tinker from your project root.

Use freely for any purpose, including commercial use, as long as you keep the copyright notice.

In plain English

Laravel Tinker is an interactive console tool for the Laravel web framework, a PHP framework commonly used to build web applications and APIs. REPL stands for Read-Eval-Print Loop, which describes a shell where you type a command, the tool runs it immediately, shows you the result, and then waits for the next input. Developers use this kind of tool to quickly test code, inspect data, or experiment with parts of their application without writing a full script or opening a browser. Tinker is built on top of PsySH, an open-source interactive PHP shell. Because it runs inside your Laravel application, it has access to all of your database models, configuration values, and services. This means you can query your database, create test records, or call any function in your codebase directly from the terminal. It is included by default in new Laravel projects. The README for this repository is very short. It describes Tinker in one sentence and directs readers to the official Laravel documentation website for full usage instructions. No setup steps or code examples are given here, all of that lives on the external docs site. If you use Laravel and want to quickly check what a piece of code does, look at data in your database, or run a one-off command against your application, Tinker is the built-in tool for that. You start it from the terminal using the artisan command-line interface that comes with every Laravel project. The source code is licensed under the MIT license and open to contributions.

Copy-paste prompts

Prompt 1
Using Laravel Tinker, show me how to query all User records from my database, filter by email domain, and print the results directly from the terminal.
Prompt 2
How do I use Laravel Tinker to create a new user record using my User model and factory, then verify it was saved to the database?
Prompt 3
I want to call a method on a Laravel service class in Tinker. How do I resolve it from the service container and invoke it interactively?
Prompt 4
What artisan command starts Laravel Tinker, and how is it different from running plain php -a? What extra access does it give me to my app?
Open on GitHub → Explain another repo

← laravel on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.