PHPackages                             terablaze/serializable-closure - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. terablaze/serializable-closure

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

terablaze/serializable-closure
==============================

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

04PHP

Since Jan 20Pushed 3y agoCompare

[ Source](https://github.com/terablaze/serializable-closure)[ Packagist](https://packagist.org/packages/terablaze/serializable-closure)[ RSS](/packages/terablaze-serializable-closure/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Serializable Closure
====================

[](#serializable-closure)

[ ![Build Status](https://github.com/terablaze/serializable-closure/workflows/tests/badge.svg)](https://github.com/terablaze/serializable-closure/actions)[ ![License](https://camo.githubusercontent.com/c886fe3dbb1a17e583b9a17c0e3e481a11d8006ddaed05d19a8c84e67e4c529e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74657261626c617a652f73657269616c697a61626c652d636c6f73757265)](https://packagist.org/packages/terablaze/serializable-closure)Introduction
------------

[](#introduction)

> This project is a fork [laravel/serializable-closure](https://github.com/laravel/serializable-closure) package, which is a fork of the excellent [opis/closure: 3.x](https://github.com/opis/closure) package.

Terablaze Serializable Closure provides an easy and secure way to **serialize closures in PHP**.

Official Documentation
----------------------

[](#official-documentation)

### Installation

[](#installation)

> **Requires [PHP 7.4+](https://php.net/releases/)**

First, install Terablaze Serializable Closure via the [Composer](https://getcomposer.org/) package manager:

```
composer require terablaze/serializable-closure
```

### Usage

[](#usage)

You may serialize a closure this way:

```
use Terablaze\SerializableClosure\SerializableClosure;

$closure = fn () => 'james';

// Recommended
SerializableClosure::setSecretKey('secret');

$serialized = serialize(new SerializableClosure($closure));
$closure = unserialize($serialized)->getClosure();

echo $closure(); // james;
```

### Caveats

[](#caveats)

1. Creating **anonymous classes** within closures is not supported.
2. Using attributes within closures is not supported.
3. Serializing closures on REPL environments such as Terablaze Repl is not supported.

License
-------

[](#license)

Serializable Closure is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity24

Early-stage or recently created project

 Bus Factor1

Top contributor holds 52.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b739d7203a863b99d21a232feebb96c8b649bf0087f46cc3d905a64d53731f5?d=identicon)[tomiwahq](/maintainers/tomiwahq)

---

Top Contributors

[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (86 commits)")[![driesvints](https://avatars.githubusercontent.com/u/594614?v=4)](https://github.com/driesvints "driesvints (43 commits)")[![taylorotwell](https://avatars.githubusercontent.com/u/463230?v=4)](https://github.com/taylorotwell "taylorotwell (16 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (6 commits)")[![keithbrink](https://avatars.githubusercontent.com/u/15267205?v=4)](https://github.com/keithbrink "keithbrink (5 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (4 commits)")[![tomiwahq](https://avatars.githubusercontent.com/u/19550920?v=4)](https://github.com/tomiwahq "tomiwahq (1 commits)")[![ksassnowski](https://avatars.githubusercontent.com/u/5139098?v=4)](https://github.com/ksassnowski "ksassnowski (1 commits)")[![morloderex](https://avatars.githubusercontent.com/u/5677808?v=4)](https://github.com/morloderex "morloderex (1 commits)")[![stefanzweifel](https://avatars.githubusercontent.com/u/1080923?v=4)](https://github.com/stefanzweifel "stefanzweifel (1 commits)")[![azjezz](https://avatars.githubusercontent.com/u/29315886?v=4)](https://github.com/azjezz "azjezz (1 commits)")

### Embed Badge

![Health badge](/badges/terablaze-serializable-closure/health.svg)

```
[![Health](https://phpackages.com/badges/terablaze-serializable-closure/health.svg)](https://phpackages.com/packages/terablaze-serializable-closure)
```

###  Alternatives

[mck89/peast

Peast is PHP library that generates AST for JavaScript code

19139.2M45](/packages/mck89-peast)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9843.5k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

45153.1k6](/packages/jstewmc-rtf)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.2k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
