# Tinker

Source: https://laraport.app/docs/tinker/

> Run PHP in the booted Laravel app on your server, Tinkerwell-style: an editor on top, the result below, with the time and memory it took.

*Screen: Tinker on production with an Eloquent query and its result*

**Tinker** runs PHP in the booted Laravel app of the container. You write code in the editor on top and see the result below:

- whatever the code prints;
- the value of the last expression, dumped with VarDumper. No `return` needed: the code runs through PsySH as `artisan tinker` does, so `use` statements work;
- for an exception, its class, message and location;
- the run time and peak memory.

```php
use App\Models\Order;

Order::where('status', 'failed')->latest()->take(5)->get(['id', 'total']);
```

## Keys

| Key | Action |
|---|---|
| `ctrl+r` or `f5` | Run |
| `esc` | Stop a running snippet |
| `ctrl+p` / `ctrl+n` | Previous / next snippet from the history |
| `ctrl+l` | Clear the output |

The history is kept per server and container in `~/.config/laraport/history.json`, with the [history settings](https://laraport.app/docs/configuration/#settings).

## Safety

- The code travels over stdin, base64-encoded. Quotes never matter and the code never shows up in process listings on the server.
- In a production app (`APP_ENV=production`), the first run asks for confirmation.
