Damp

Tinker

Interactive PHP shell for projects

Open an interactive PHP shell for any project with a single click. Test code, query your database, and interact with your application directly from the terminal.

One-Click Access

Every project in DAMP has a "Open Tinker" button that launches a terminal with Tinker already running!

Quick Start

Launch Tinker in three clicks:

Ensure Devcontainer is Running

Open your Laravel project in VS Code and reopen in container.

Click "Open Tinker"

Find the Tinker button in your project dashboard in DAMP.

Start Experimenting

A terminal window opens with Tinker ready - start typing commands!

Features

One-Click Launch

No commands to remember - just click and start coding

Full Laravel Access

Access models, facades, helpers, and your entire application

Database Queries

Query and manipulate data without writing SQL

Live Testing

Test functions, classes, and logic in real-time

What is Tinker?

Tinker is Laravel's powerful REPL (Read-Eval-Print Loop) powered by PsySH. It provides an interactive console where you can:

  • Execute PHP code instantly
  • Interact with your Laravel application
  • Query the database using Eloquent
  • Test methods and functions
  • Debug and troubleshoot

REPL Environment

Tinker runs inside your devcontainer with full access to your Laravel application, including database connections, environment variables, and all your code.

Common Use Cases

πŸ” Query Database

Fetch and inspect data using Eloquent:

>>> User::all();
>>> User::where('email', 'john@example.com')->first();
>>> User::count();

βž• Create Records

Insert test data quickly:

>>> $user = new User;
>>> $user->name = 'Jane Doe';
>>> $user->email = 'jane@example.com';
>>> $user->save();

πŸ§ͺ Test Functions

Try out methods before implementing:

>>> Str::slug('Hello World');
=> "hello-world"

>>> Hash::make('password123');
=> "$2y$10$..."

πŸ”§ Debug Issues

Inspect objects and relationships:

>>> $user = User::find(1);
>>> $user->posts;
>>> $user->posts()->count();

πŸ“§ Test Notifications

Send test emails and notifications:

>>> $user = User::first();
>>> $user->notify(new WelcomeNotification);

🌐 Test API Calls

Make HTTP requests:

>>> Http::get('https://api.example.com/data');
>>> Http::post('https://api.example.com/users', ['name' => 'John']);

How It Works

When you click "Open Tinker", DAMP:

  1. βœ… Checks that your devcontainer is running
  2. βœ… Opens a new terminal window
  3. βœ… Executes: docker exec -it {project}_devcontainer php artisan tinker
  4. βœ… You're in Tinker - ready to code!
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   DAMP Dashboard                    β”‚
β”‚   Click "Open Tinker" β†’             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
             ↓
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   New Terminal Window Opens         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ $ docker exec -it myapp_devcontainerβ”‚
β”‚   php artisan tinker                β”‚
β”‚                                     β”‚
β”‚ Psy Shell v0.12.0                   β”‚
β”‚ >>> _                               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Tips & Tricks

Show Available Commands

>>> help

Lists all available Tinker commands and shortcuts.

Clear Screen

>>> clear

Or press Ctrl+L to clear the terminal.

View Variables

>>> show $user

Displays formatted output of any variable.

Multi-Line Code

Press Enter without completing statement:

>>> $users = User::where('active', true)
...           ->orderBy('created_at', 'desc')
...           ->take(10)
...           ->get();

History

Use ↑ and ↓ arrow keys to navigate through command history.

Exit Tinker

>>> exit

Or press Ctrl+D to quit Tinker.

Pro Tip: Save Your Work

Tinker doesn't persist session state. If you're building complex queries, save them in a file for later!

Helpful Commands

CommandDescription
helpShow available commands
lsList variables in current scope
show $varDisplay formatted variable
doc ClassNameShow class documentation
clearClear screen
exitQuit Tinker

Requirements

Devcontainer Must Be Running

Before clicking "Open Tinker":

  1. Open your project in VS Code
  2. Run "Dev Containers: Reopen in Container"
  3. Wait for container to fully start
  4. Now click "Open Tinker" in DAMP

Troubleshooting


Interactive Development

Use Tinker to experiment, debug, and test your Laravel application in real-time - all with a single click from DAMP!

Learn More