luminarix / laravel-web-tinker
Small Laravel package to use Tinker in your browser
Fund package maintenance!
luminarix
Installs: 1 760
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Language:TypeScript
Requires
- php: ^8.3
- illuminate/contracts: ^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.15
- nunomaduro/collision: ^8.1.1
- orchestra/testbench: ^9.0.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
README
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.
🚨 A word to the wise 🚨
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.
Known issues
- None. Please report any issues you find.
Requirements
- PHP ^8.3
- Laravel ^11.0
Extra features
- 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
Installation
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
Usage
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.
Authorization
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
.
Modifying the output
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.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.