eptic/turbo
Composer 安装命令:
composer require eptic/turbo
包简介
Helpers for making Hotwired Turbo work with Laravel
README 文档
README
Installation
You can install the package via composer:
composer require eptic/turbo
As per the official @Hotwired/Turbo documentation, you will need to add the TurboMiddleware provided in this package to the web group inside Kernel.php to handle the redirects as Turbo expects them.
You can read more information about this in the official documentation:
Redirecting After a Form Submission
Example:
'web' => [ \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, -> \Eptic\Turbo\Middleware\TurboMiddleware::class, ],
You can publish the config file with:
php artisan vendor:publish --tag="turbo-config"
Optionally, you can publish the views used as templates using
php artisan vendor:publish --tag="turbo-views"
You can see the content of the config file in the configs folder.
Usage
Turbo Frames
To generate a turbo frame response
return response()->turboFrame()->generic(id: 'gallery', partial: view('pages.galleries._partials.create'), target: '#gallery-create');
Check if the request was made inside a turbo-frame:
request()->wantsTurboFrame()
Turbo Streams
To check if a request is a turbo stream request:
request()->expectsTurboStream()
To generate a turbo stream, you can use the turboStream method on the response object.
It has all the signatures present in the original documentation from Hotwired:
- Append:
return response()->turboStream()->append(target: 'gallery-create', partial: view('pages.galleries._partials.create'));
- Prepend:
return response()->turboStream()->prepend(target: 'gallery-create', partial: view('pages.galleries._partials.create'));
- Replace:
return response()->turboStream()->replace(target: 'gallery-create', partial: view('pages.galleries._partials.create'));
- Update:
return response()->turboStream()->update(target: 'gallery-create', partial: view('pages.galleries._partials.create'));
- Remove:
return response()->turboStream()->remove(target: 'gallery-create');
- Before:
return response()->turboStream()->before(target: 'gallery-create', partial: view('pages.galleries._partials.gallery'));
- After:
return response()->turboStream()->after(target: 'gallery-create', partial: view('pages.galleries._partials.gallery'));
If you already have a view that contains the entire template and only want to set the correct content-type so it is recognised as a turbo stream, you can use:
return response()->turboStream()->view(view: 'pages.galleries.create', data: $data); // Or you can pass in a view directly return response()->turboStream()->view(view: view('pages.galleries.create', $data));
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
eptic/turbo 适用场景与选型建议
eptic/turbo 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 116 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 12 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「turbo」 「eptic」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 eptic/turbo 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 eptic/turbo 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 eptic/turbo 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP5.4 Yandex Turbo Pages RSS feed generator
A Laravel package to manage application menus
Turbocharge Laravel Nova by lazy loading resources. Dramatically improves performance for applications with 50+ resources.
TurboSMS HTTP API library, This package allows easy notification sending using [turbosms.ua](https://turbosms.ua). Optimized for php5.4 and above
This plugin utilizes the PageCache filter from yii2 into your craft 3 instance
Symfony 8 bundle for GDPR/DSGVO cookie consent with Google Consent Mode v2, Twig components, Stimulus.js, and AssetMapper. Supports cookie, Doctrine, or combined storage. Includes YouTube, Vimeo, Google Maps embed components.
统计信息
- 总下载量: 116
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-04
