定制 luminarix/laravel-web-tinker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

luminarix/laravel-web-tinker

最新稳定版本:v1.1.0

Composer 安装命令:

composer require luminarix/laravel-web-tinker

包简介

Small Laravel package to use Tinker in your browser

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.

  1. You must register a viewWebTinker ability. A good place to do this is in the AuthServiceProvider that ships with Laravel.
public function boot()
{
    $this->registerPolicies();

    Gate::define('viewWebTinker', function ($user = null) {
        // return true if access to web tinker is allowed
    });
}
  1. You must set the enabled variable in the web-tinker config file to true.

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.

统计信息

  • 总下载量: 4.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: TypeScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-15