Search by

themehybrid / hybrid-serializable-closure

saas786

Hybrid Core Serializable Closure provides an easy and secure way to serialize closures in PHP.

Package info

github.com/themehybrid/hybrid-serializable-closure

Forum

pkg:composer/themehybrid/hybrid-serializable-closure

Statistics

Installs: 1

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

1.0.0 2026-10-23 06:06 UTC

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.