Oh Dear is the all-in-one monitoring tool for your entire website. We monitor uptime, SSL certificates, broken links, scheduled tasks and more. You'll get a notifications for us when something's wrong. All that paired with a developer friendly API and kick-ass documentation. O, and you'll also be able to create a public status page under a minute. Start monitoring using our free trial now.

A package to use Artisan Tinker in your browser

Original – by Freek Van der Herten – 2 minute read

Laravel comes with a very handy tinker command out of the box. Unfortunately running multiple lines of code on the command line, or editing the code you just executed, can be a bit bothersome. That's why we created a new package called laravel-web-tinker that allows you to run arbitrary code in your browser.

Once installed this is what it looks like:

Web tinker in the browser

There's also a dark mode available:

Web tinker in dark mode on the brower

Under the hood, it works like this. Whenever you press cmd+enter the code will be sent via an HTTP request to the server. The WebTinkerContoller will just pass the code through the Tinker class. The code will be executed there and the results will be returned as the response. Nothing special going there.

Because this package can run code arbitrarily we recommend against installing it in a production environment, or any environment where you handle real-world data. We urge you to install the package using the --dev flag

composer require spatie/laravel-web-tinker --dev

This means that the package will not be installed when you run composer install --no-dev on your production server (this is something you should be doing already).

There are some more config options. Check out the readme on GitHub to learn more about the package.

Happy tinkering!

Stay up to date with all things Laravel, PHP, and JavaScript.

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

What are your thoughts on "A package to use Artisan Tinker in your browser"?

Comments powered by Laravel Comments
Want to join the conversation? Log in or create an account to post a comment.