TinkerPad
Run Laravel Tinker scratch files from VS Code without pasting file contents into the terminal.
TinkerPad looks for .php files inside a workspace .tinkerpad directory, starts an interactive Artisan Tinker session, requires the current file, and leaves the session open for follow-up commands.
Quick start
- Create a
.tinkerpad directory in a Laravel workspace.
- Add a PHP scratch file, for example
.tinkerpad/scratch.php.
- Open the file and run Tinkerpad: Run Current File from the Command Palette, or use the Run Tinkerpad CodeLens above the file.
By default TinkerPad runs:
php artisan tinker
Commands
- Tinkerpad: Run Current File
- Starts Tinker and requires the active
.tinkerpad/*.php file.
- Run Tinkerpad CodeLens
- Appears at the top of
.php files inside .tinkerpad.
- Tinkerpad: Diagnose CodeLens
- Writes CodeLens diagnostics to the Tinkerpad Diagnostics output channel.
Requirements
- A Laravel workspace with
php artisan tinker available, or a custom command configured in .tinkerpad/config.json or .tinkerpad/config.local.json.
- PHP files must live inside a
.tinkerpad directory.
- Kubernetes profiles require
kubectl to be installed and authenticated for the configured context.
- The VS Code workspace must be trusted before TinkerPad will run commands.
Configuration
Create .tinkerpad/config.json in your workspace to define one or more named profiles:
{
"profiles": {
"local": {
"command": "./vendor/bin/sail artisan tinker",
"verbose": false
}
}
}
When more than one profile is configured, TinkerPad asks which profile to use on every run. A single profile is selected automatically.
Add a valid kubernetes object to a profile to run its command inside a Kubernetes container:
{
"profiles": {
"local": {
"command": "./vendor/bin/sail artisan tinker"
},
"production": {
"command": "php artisan tinker",
"verbose": false,
"kubernetes": {
"context": "production",
"namespace": "apps-prod",
"podNamePrefix": "backend-",
"container": "php-fpm",
"remoteTempDirectory": "/tmp"
}
}
}
}
If no configuration file or profile command is present, TinkerPad uses php artisan tinker. If verbose is missing, it uses false. A profile without kubernetes runs locally. An incomplete kubernetes object is rejected instead of falling back to local execution.
Create .tinkerpad/config.local.json for machine-specific overrides. TinkerPad reads .tinkerpad/config.json first, then deep-merges .tinkerpad/config.local.json by profile name, so nested values can be overridden without repeating the full profile:
{
"profiles": {
"production": {
"verbose": true,
"kubernetes": {
"namespace": "apps-local"
}
}
}
}
Migrating older configuration
When TinkerPad encounters the previous root-level format, it automatically rewrites each configuration file to named profiles before running:
localCommand becomes profiles.local.command.
kubernetesCommand becomes profiles.kubernetes.command.
- The legacy
command is used by both generated profiles unless overridden by the mode-specific command.
verbose is copied to both generated profiles.
- A
kubernetes profile is generated only when a complete Kubernetes object is available after merging shared and local configuration.
config.json and config.local.json remain separate so local overrides are preserved.
The legacy mode value is removed. When both generated profiles are available, TinkerPad asks which one to use. Invalid legacy configuration is not rewritten.
Custom profile commands are executable workspace configuration. Only use them in projects you trust; TinkerPad asks for confirmation before running a custom command for the first time in the current VS Code session.
You can also disable the editor CodeLens from VS Code settings:
{
"tinkerpad.codeLens.enabled": false
}
Behavior
- Only runs when the active file is a
.php file inside a .tinkerpad directory.
- Shows
Run Tinkerpad at the top of runnable files when tinkerpad.codeLens.enabled is enabled.
- Closes the previous Tinkerpad terminal before each run.
- Saves and executes the current
.tinkerpad file by path, so the file code is not printed in the terminal.
- Starts an interactive Tinker session, runs the current file inside it, and keeps that same session open.
- Reads
.tinkerpad/config.json and .tinkerpad/config.local.json to select named local/Kubernetes profiles.
- Does not run in untrusted VS Code workspaces.
- Asks for confirmation before running a custom command from workspace configuration.
- For Kubernetes profiles, uploads the current file to a temporary file in the container, requires it inside Tinker, and keeps the remote Tinker session open.