Tinkerwell 4 is out now! See what's new or buy now.
Tinkerwell background image
Tinkerwell Logo Tinkerwell
Go back to Blog

Curing the browser-refresh-loop

The browser-refresh-loop is the annoying process of writing PHP code, switching to your browser and refreshing the site to see if your code does what you want. As PHP developers, we’ve made this a habit in the last 20 years because that is how we do web development.

Our tech stack in PHP runs either on requests that a web server serves and that come from a browser or by CLI invocations from the command line – but in every case you write code, switch to a 2nd application and run the code.

This process is painful, time consuming and it often interrupts your flow when writing code – especially when you are in the early process of a new feature that doesn’t have a GUI yet or when you debug an issue and simply use the browser-refresh-loop to dump out values and objects in the browser without any GUI at all.

Luckily, there is a solution to that: 💫 Tinkerwell

Tinkerwell allows you to write and run code in the context of your application and getting results without switching to the browser. It even makes it possible to connect to a an application in production and running code without interrupting the live site.

What does that even mean?
#

If we stick to debugging issues on a production environment, you can’t simply add a dd() or var_dump() to the code without showing this debug output to visitors who are browsing the site right now.

Tinkerwell allows you to write a temporary code snippet that fetches the object in question from a database and analyzing the data without actually changing the code. It allows you to manually pull together data and pass it to a job that needs to run a 2nd time or dispatch an event that had an issue before. When using Laravel, you can write complex Eloquent queries that display data but also modify records without using difficult SQL queries. Simply use the framework that you use all day with all its benefits.

Daily development
#

Instead of writing a few lines of code, switching to the browser and refreshing it, simply write the code in Tinkerwell and run it with a shortcut. This gives you instant results in the view that fits best to your current situation. Fetching and working with a single record? It displays the result of the code and you can directly see if it’s correct. Grabbing multiple elements from a database or working with arrays or collections? Tinkerwell can display a table view with the result that makes the content easy to understand and even exportable via a convenient CSV export. Returning a Mailable? Tinkerwell can display a preview of the email without actually going through the process of sending the email.

Once the code does exactly what you want, copy it to your application, fill the the temporary values with request information and you are good.

By skipping the browser-refresh-loop, you can enjoy writing PHP code like a frontend developer who uses BrowserSync to instantly see the results of their changes. And that’s just the tip of the iceberg. Tinkerwell is so versatile that there is no way to describe it as the solution to a specific coding problem – it’s the solution to speed up your development process and give you remote debugging capabilities that are far beyond the examples in this article.

James Brooks, Developer at Laravel
“Seriously, Tinkerwell is great, I genuinely use it every single day for testing snippets or checking production data.”
James Brooks

Developer at Laravel

Christopher Koye, CEO
“All colleagues that work with PHP use Tinkerwell. And it really helps.”
Christopher Koye

CEO

Tinkerwell: The PHP Scratchpad

The must-have companion to your favorite IDE. Quickly iterate on PHP code within the context of your web application.

Buy now Learn more