Skip to content

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:

php
// 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:

php
// 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:

FormatDescriptionDisplay
PHPObjects, arraysFormatted dump
JSONJSON stringsSyntax highlighted
HTMLHTML contentRendered or raw
SQLQuery resultsTable view
CSVComma-separatedTable view
PlainSimple textMonospace text

Collection Output

Eloquent collections get special formatting:

php
User::limit(3)->get()

Output shows as an expandable collection with model attributes.

Execution History

Access previous executions:

  1. Click the History icon in the toolbar
  2. Browse past code and outputs
  3. 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 Timeout

For 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.

Built for Laravel developers.