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:
- β Checks that your devcontainer is running
- β Opens a new terminal window
- β
Executes:
docker exec -it {project}_devcontainer php artisan tinker - β 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
>>> helpLists all available Tinker commands and shortcuts.
Clear Screen
>>> clearOr press Ctrl+L to clear the terminal.
View Variables
>>> show $userDisplays 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
>>> exitOr 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
| Command | Description |
|---|---|
help | Show available commands |
ls | List variables in current scope |
show $var | Display formatted variable |
doc ClassName | Show class documentation |
clear | Clear screen |
exit | Quit Tinker |
Requirements
Devcontainer Must Be Running
Before clicking "Open Tinker":
- Open your project in VS Code
- Run "Dev Containers: Reopen in Container"
- Wait for container to fully start
- 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!