themehybrid / hybrid-serializable-closure
Hybrid Core Serializable Closure provides an easy and secure way to serialize closures in PHP.
Package info
github.com/themehybrid/hybrid-serializable-closure
pkg:composer/themehybrid/hybrid-serializable-closure
Requires
- php: >=8.2
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-24 05:53:40 UTC
README
Hybrid Serializable Closure provides an easy and secure way to serialize closures in PHP.
Requirements
- PHP 8.2+.
- Composer for managing PHP dependencies.
Installation
First, install Hybrid Core Serializable Closure via the Composer package manager:
composer require themehybrid/hybrid-serializable-closure
Usage
You may serialize a closure this way:
use Hybrid\SerializableClosure\SerializableClosure; $closure = fn () => 'james'; // Recommended SerializableClosure::setSecretKey('secret'); $serialized = serialize(new SerializableClosure($closure)); $closure = unserialize($serialized)->getClosure(); echo $closure(); // james;
Caveats
- Multiple closures defined on the same source line with identical signatures may not be distinguishable after serialization. Place each closure on its own line to avoid this.
Copyright and License
This project is licensed under the GNU GPL, version 2 or later.
2008 – 2026 © Theme Hybrid.
Third-Party Licenses
Hybrid Serializable Closure utilizes code from Laravel.
Repository: https://github.com/laravel/serializable-closure
License: MIT License, included in full in LICENSE-laravel.md.
Copyright (c) Taylor Otwell
The test suite in qa/ is ported from the same repository, under the same
license.