A Quick way to flash & share Hybridly Variables from anywhere, persisting on session & processes.
flavorly/hybridly-share is a Laravel package for a quick way to flash & share hybridly variables from anywhere, persisting on session & processes..
It currently has 2 GitHub stars and 40 downloads on Packagist (latest version v0.0.2).
Install it with composer require flavorly/hybridly-share.
Discover more Laravel packages by flavorly
or browse all Laravel packages to compare alternatives.
Last updated

A Quick way to flash & share variables to Hybridly that persist on session or cache & across requests different requests.
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*',
],
];
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');
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 :
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.
composer test
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.