flavorly/hybridly-share
Composer 安装命令:
composer require flavorly/hybridly-share
包简介
A Quick way to flash & share Hybridly Variables from anywhere, persisting on session & processes.
README 文档
README
A Quick way to flash & share variables to Hybridly that persist on session or cache & across requests different requests.
Installation
You can install the package via composer:
composer require flavorly/hybridly-share
You can publish the config file with:
php artisan vendor:publish --tag="hybridly-share-config"
This is the contents of the published config file:
<?php return [ /* |-------------------------------------------------------------------------- | Driver Configuration |-------------------------------------------------------------------------- | | You can configure hybridly share to use session or cache as the driver. | when using the cache driver hybridly share will leverage your current | cache driver and attempt to save the temporary shared keys there. | A unique key is used to generate the unique key for each user | | Drivers: 'cache' or 'session' are supported. | Prefix Key : hybridly_container_ | Cache TTL : Time in seconds to store the keys in cache. */ 'prefix_key' => 'hybridly_container_', 'driver' => 'session', 'session-driver' => \Flavorly\HybridlyShare\Drivers\SessionDriver::class, 'cache-driver' => \Flavorly\HybridlyShare\Drivers\CacheDriver::class, 'cache-ttl' => 60, /* |-------------------------------------------------------------------------- | Persistent Keys |-------------------------------------------------------------------------- | | Here you may configure the keys that should be persisted on the session, | even if they are empty they will be mapped to their primitives configured here. | Might not be needed since hybridly provides a persist method. */ 'persistent-keys' => [ // 'some-key' => 'some-value', // 'messages => [], ], /* |-------------------------------------------------------------------------- | Ignore URLs & Params |-------------------------------------------------------------------------- | | The URls to ignore by default, because hybridly runs on web middleware | Default For URLS: ['broadcasting/auth',...] | */ 'ignore_urls' => [ 'nova-api*', 'filament-api*', 'broadcasting/auth', 'telescope*', 'horizon*', '_debugbar*', '_ignition*', ], ];
Usage
You can use the Hybridly Share helper anywhere from your code and share your variables directly to Hybridly. Keep in the mind that the values will only be kept on the current or next request lifecycle, they will be flushed once shared to Hybridly. You may also use closures that under-the-hood will be converted to Laravel Closure Serializer ( Previously Opis )
// Or using the helper hybridly()->container()->share('foo', 'bar'); hybridly()->container()->share('foo', fn() => 'bar'); hybridly()->container()->append('fruits','bananas'); hybridly()->container()->append('fruits','potatoes'); hybridly()->container()->share('foo', ['bar' => 'foo', 'baz' => fn() => 'bar']); // On Controllers return back() return back()->hybridly('foo', 'bar'); return back()->hybridly('foo', fn() => 'bar'); // Conditional Sharing hybridly()->container()->shareIf($foo === true, 'foo', 'bar'); hybridly()->container()->shareUnless($foo === false, 'foo', 'bar'); // Sharing to a user // Only available if driver is cache, otherwise session will always use the current logged user hybridly()->container()->forUser($user)->append('foo', 'bar');
Why Hybridly Share?
This package is intended to be used with the Hybridly framework. Hybridly provides a nice way to share variables, but sometimes you might want the data to persist on the session or cache.
Few use cases :
- Sharing data before a redirect ( Ex: back()->with('foo','bar') can be replicated with back()->hybridly('foo','bar') )
- Sharing data from a request that will end up on a redirect or a new lifecycle.
- Sharing data from a service directly
- Sharing data from any point of your code before serving a request/page
- Sharing data from a command/job to a specific user
- Avoiding Hybridly Middleware pollution with sharing session variables back and forth.
- etc..
If you are looking for real-time sharing this package might not be your best choice, and would recommend using Laravel Echo paired together with Pusher or Soketi.
Testing
composer test
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.
flavorly/hybridly-share 适用场景与选型建议
flavorly/hybridly-share 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 04 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「hybridly」 「flavorly」 「hybridly-flash」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 flavorly/hybridly-share 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 flavorly/hybridly-share 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 flavorly/hybridly-share 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Server-driven, client-rendered application.
Vanilla Components Integration with Laravel
A tool of tiny but useful Laravel Helpers that we use across our projects
A Quick way to flash & share InertiaJS Variables from anywhere, persisting on session.
Generate a new IDE Helper file for Laravel Actions.
Alfabank REST API integration
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-12
