Artisan 的tinker 命令是在终端中修改应用程序的好方法。不幸的是,运行几行代码、进行编辑以及复制/粘贴代码可能会很麻烦。在浏览器中进行修改不是很好吗?
该软件包将为您的应用程序添加一条路线,您可以在其中随意修改。
如果光线伤害你的眼睛,还有黑暗模式。
我们投入了大量资源来创建一流的开源包。您可以通过购买我们的一款付费产品来支持我们。
我们非常感谢您从家乡寄给我们一张明信片,并注明您正在使用我们的哪种套餐。您可以在我们的联系页面上找到我们的地址。我们在虚拟明信片墙上发布所有收到的明信片。
该包可以运行任意代码。除非您知道自己在做什么,否则切勿在生产环境或处理真实世界数据的任何环境中安装或使用它。
您可以通过 Composer 安装该软件包:
composer require spatie/laravel-web-tinker --dev
接下来,您必须通过运行此命令来发布此包中的资产。
php artisan web-tinker:install
或者,您可以发布包的配置文件。
php artisan vendor:publish --provider= " SpatieWebTinkerWebTinkerServiceProvider " --tag= " config "
这是将发布到config/web-tinker.php
的内容
return [
/*
* The web tinker page will be available on this path.
*/
' path ' => ' /tinker ' ,
/*
* Possible values are 'auto', 'light' and 'dark'.
*/
' theme ' => ' auto ' ,
/*
* By default this package will only run in local development.
* Do not change this, unless you know what your are doing.
*/
' enabled ' => env ( ' APP_ENV ' ) === ' local ' ,
/*
* This class can modify the output returned by Tinker. You can replace this with
* any class that implements SpatieWebTinkerOutputModifiersOutputModifier.
*/
' output_modifier ' => Spatie WebTinker OutputModifiers PrefixDateTime::class,
/*
* These middleware will be assigned to every WebTinker route, giving you the chance
* to add your own middlewares to this list or change any of the existing middleware.
*/
' middleware ' => [
Illuminate Cookie Middleware EncryptCookies::class,
Illuminate Session Middleware StartSession::class,
Spatie WebTinker Http Middleware Authorize::class,
],
/*
* If you want to fine-tune PsySH configuration specify
* configuration file name, relative to the root of your
* application directory.
*/
' config_file ' => env ( ' PSYSH_CONFIG ' , null ),
];
默认情况下,此包仅在本地环境中运行。
在应用程序的本地环境中访问/tinker
以查看修补程序页面。
如果您想在其他环境中运行此程序(我们不建议这样做),则必须执行两个步骤。
viewWebTinker
功能。执行此操作的一个好地方是 Laravel 附带的AuthServiceProvider
。 public function boot ()
{
$ this -> registerPolicies ();
Gate:: define ( ' viewWebTinker ' , function ( $ user = null ) {
// return true if access to web tinker is allowed
});
}
web-tinker
配置文件中的enabled
变量设置为true
。 您可以通过在web-tinker
配置文件的output_modifier
键中指定输出修饰符来修改tinker 的输出。输出修饰符是任何实现SpatieWebTinkerOutputModifiersOutputModifier
的类。
这就是该界面的样子。
namespace Spatie WebTinker OutputModifiers ;
interface OutputModifier
{
public function modify ( string $ output = '' ): string ;
}
该软件包的默认安装将使用PrefixDataTime
输出修饰符,该修饰符在 Tinker 的输出中添加当前日期时间的前缀。
composer test
请参阅变更日志以了解有关最近更改内容的更多信息。
详细信息请参阅贡献。
如果您发现有关安全的错误,请发送邮件至 [email protected],而不是使用问题跟踪器。
该软件包的灵感来自于 Marcel Pociot 的 nova-tinker-tool 软件包,并使用了其中的代码。
麻省理工学院许可证 (MIT)。请参阅许可证文件以获取更多信息。