Tutorial
Run tinker on a serverless Laravel app, without SSH
One line of PHP in your live Laravel environment, with no server to SSH into: brewless tinker runs tinker --execute in your own container and prints the answer.
In this post
Sooner or later you want to ask a live Laravel application one question that no page shows: how many users signed up today, what a config value is in production, whether that one order really has no invoice. On a server you SSH in and type php artisan tinker. On serverless there is no server to SSH into, and nothing stays running.
Since 24 November 2026 Brewless has brewless tinker for that.
How do you run tinker on serverless Laravel?
Give the environment and one line of PHP:
brewless tinker production "App\\Models\\User::whereDate('created_at', today())->count()"
The line runs with tinker --execute in the environment's own container, on the release that is live, next to its database, and you get back what tinker prints: the value of the last expression, or the exception. Nothing is installed on a server and no port is opened. The request goes the same way as any one-off command, with the environment's own secret.
Why only one line, and no shell?
A serverless container answers a request and then stops; it does not keep a terminal open while you think. An interactive tinker waits for typing and never ends by itself, so Brewless refuses it, and says what to use instead. tinker --execute runs the code it is given and ends, which is exactly what fits.
One line goes further than it sounds. Separate statements with semicolons, and the value of the last one is printed:
brewless tinker staging "\$order = App\\Models\\Order::find(4211); \$order?->invoice()->exists()"
For work that takes longer than 50 seconds, or that you want to run more than once, an artisan command or a queued job is the better home.
What does the client do for you?
brewless tinker |
|
|---|---|
| Quoting | The code is quoted for the framework's console, so quotes, $ and backslashes arrive as typed |
| Production | Shows the code and asks first; --force skips that |
| Exit code | Tinker's own: 0 when the code ran, 1 when it threw |
| Time | 50 seconds, like any command |
| Audit trail | That tinker ran, by whom and where; never the code or the output |
In the shell, put the code between double quotes and escape $ and backslashes, or between single quotes and type it as it is.
Warning
Tinker runs any PHP with your application's rights, against real data. Use it to read. Keep changes to data in a command or a migration that is reviewed along with your code.
What do you need?
brewless/laravel 1.11.1 or later in the application, and laravel/tinker in its require, which a new Laravel application has. On your machine, the Brewless CLI 1.6 or later:
composer require brewless/laravel:^1.11.1
composer global require "brewless/cli:^1.6"
Deploy once so the new package is live, and brewless tinker works. An older brewless/laravel refuses tinker, and the client says so.
The details are in the documentation on commands.
Frequently asked questions
How do I run tinker on a Laravel app without SSH?
On Brewless, run brewless tinker followed by the environment and the PHP, for example brewless tinker production "App\\Models\\User::count()". It runs tinker --execute in the environment's own container and prints the result, with no server or SSH access needed.
Why can I not open an interactive tinker shell?
A serverless container answers a request and stops; it does not keep a terminal open for you to type into. Tinker with --execute runs the code it is given and ends, which fits that. For several steps, put them on one line separated by semicolons, or write an artisan command.
Is it safe to run tinker against production?
Tinker runs any PHP with your application's rights against real data, so treat it like a console on the server. The client shows the code and asks first on production, and the run has 50 seconds. Keep changes to data in a reviewed command or migration, and use tinker to read.
Does Brewless store the code I run with tinker?
No. Brewless passes the line on to your container and the output back to you. The audit trail records who ran tinker and when, not the code and not what it printed.
What do I need to use brewless tinker?
brewless/laravel 1.11.1 or later and laravel/tinker in the require section of your application, which a new Laravel application has, and the Brewless CLI 1.6 or later. An older brewless/laravel refuses tinker.