Code Execution
Run PHP code with Laravel Tinker directly in Laradebug.
Overview
The code editor is powered by Monaco (the same editor as VS Code) with Laravel-specific enhancements:
- PHP syntax highlighting
- Laravel class autocompletion
- Execution history
- Multi-format output display
Writing Code
Type PHP code in the editor. Laravel's autoloading means you can use any class without imports:
// Eloquent queries
User::where('active', true)->count()
// Facades
Cache::get('key')
// Helpers
collect([1, 2, 3])->sum()Running Code
Execute your code with:
- Keyboard:
Cmd + R - Button: Click "Run" in the toolbar
Execution Behavior
Laradebug automatically wraps your code to capture output:
// Your code:
User::first()
// Laradebug wraps it as:
dump(User::first())If your code already has output statements (dump(), dd(), ray(), echo), it won't be wrapped.
Output Formats
Laradebug detects and formats different output types:
| Format | Description | Display |
|---|---|---|
| PHP | Objects, arrays | Formatted dump |
| JSON | JSON strings | Syntax highlighted |
| HTML | HTML content | Rendered or raw |
| SQL | Query results | Table view |
| CSV | Comma-separated | Table view |
| Plain | Simple text | Monospace text |
Collection Output
Eloquent collections get special formatting:
User::limit(3)->get()Output shows as an expandable collection with model attributes.
Execution History
Access previous executions:
- Click the History icon in the toolbar
- Browse past code and outputs
- Click to load code back into the editor
History includes:
- Code executed
- Output produced
- Execution time
- Timestamp
Timeout Handling
Long-running code has a default 30-second timeout.
Adjusting Timeout
Settings → General → Default TimeoutFor one-off long operations, consider breaking them into smaller chunks or adjusting the global timeout.
Tips
Quick Iteration
Use Cmd + K to clear output, then Cmd + R to run fresh.
Related Features
- SQL Logging — See queries from your code
- Ray Integration — Debug with Ray
- Autocompletion — Code suggestions