PHPackages                             mjohann/call-morph - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mjohann/call-morph

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mjohann/call-morph
==================

CallMorph is a PHP class that simplifies and secures the serialization of anonymous functions by automatically selecting the appropriate library based on the PHP version, with support for a secret key when using Laravel's Serializable Closures.

v1.1.0(1y ago)051MITPHPPHP ^7.0|^8.0

Since Apr 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/matheusjohannaraujo/call-morph)[ Packagist](https://packagist.org/packages/mjohann/call-morph)[ RSS](/packages/mjohann-call-morph/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (1)

[Call Morph](https://github.com/matheusjohannaraujo/call-morph)
===============================================================

[](#call-morph)

**CallMorph** is a PHP class that provides a simple and secure interface for serializing and unserializing anonymous functions (Closures). It automatically detects the PHP version and uses the appropriate library for maximum compatibility and security, including support for a secret key when using Laravel's Serializable Closures.

📦 Installation
--------------

[](#-installation)

You can install the library via [Packagist/Composer](https://packagist.org/packages/mjohann/call-morph):

```
composer require mjohann/call-morph
```

⚙️ Requirements
---------------

[](#️-requirements)

- PHP 7.0 or higher
- For PHP &gt;= 8.1: [laravel/serializable-closure](https://packagist.org/packages/laravel/serializable-closure) must be installed.
- For PHP &lt; 8.1: [opis/closure](https://packagist.org/packages/opis/closure) is required.

🚀 Features
----------

[](#-features)

- Serialize and unserialize Closures with automatic compatibility based on PHP version
- Supports secret key configuration for secure serialization in Laravel
- Simple and clean API

### Available Methods

[](#available-methods)

- `__construct(string $secret)`
- `getSecret(): string`
- `setSecret(string $secret): void`
- `serialize(Closure $callback): string`
- `unserialize(string $callback): Closure`

🧪 Usage Example
---------------

[](#-usage-example)

### Publisher

[](#publisher)

```
