This package allows you to use Tinker in your browser. Wildly inspired by Spatie's Laravel Web Tinker, but with added functionality, and React frontend.
This package can run arbitrary code. Unless you know what you are doing, you should never install or use this in a production environment, or any environment where you handle real world data.
- None. Please report any issues you find.
- PHP ^8.3
- Laravel ^11.0
- Tabs for multiple code snippets
- Tabs can be renamed
- Tabs have their own code history
- Both of the above are saved in local storage, so they persist between sessions and page reloads
- Runtime counter displayed while loading and total runtime displayed in the final output
- Loading state is displayed while the code is running
If you've used Spatie's Laravel Web Tinker before, please remove the config/web-tinker.php file before installing this package.
You can install the package via composer:
composer require luminarix/laravel-web-tinker
Publish the assets:
php artisan vendor:publish --tag="laravel-web-tinker-assets"
You can publish the config file with:
php artisan vendor:publish --tag="laravel-web-tinker-config"
Optionally, you can publish the views using
php artisan vendor:publish --tag="laravel-web-tinker-views"
Or if you want to publish everything at once, you can use
php artisan laravel-web-tinker:install
By default this package will only run in a local environment.
Visit /tinker
in your local environment of your app to view the tinker page.
Should you want to run this in another environment (we do not recommend this), there are two steps you must perform.
- You must register a
viewWebTinker
ability. A good place to do this is in theAuthServiceProvider
that ships with Laravel.
public function boot()
{
$this->registerPolicies();
Gate::define('viewWebTinker', function ($user = null) {
// return true if access to web tinker is allowed
});
}
- You must set the
enabled
variable in theweb-tinker
config file totrue
.
You can modify the output of tinker by specifying an output modifier in the output_modifier
key of the web-tinker
config file. An output modifier is any class that implements \Luminarix\LaravelWebTinker\OutputModifiers\OutputModifier
.
This is how that interface looks like.
namespace Luminarix\LaravelWebTinker\OutputModifiers;
interface OutputModifier
{
public function modify(string $output = ''): string;
}
The default install of this package will use the PrefixDataTime
output modifier which prefixes the output from Tinker with the current date time and the run-time of the code.
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.