定制 mjohann/call-morph 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mjohann/call-morph

最新稳定版本:v1.1.0

Composer 安装命令:

composer require 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.

README 文档

README

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

You can install the library via Packagist/Composer:

composer require mjohann/call-morph

⚙️ Requirements

🚀 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

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

🧪 Usage Example

Publisher

<?php

use MJohann\Packlib\CallMorph;

require_once "vendor/autoload.php";

$name = "Johann";
$closure = function () use ($name) {
    sleep(1);
    return "My name is " . $name . " - Rand: " . rand(0, 999);
};

$cm = new CallMorph("secret");
$serialized = $cm->serialize($closure);
echo "CallMorph->serialize", PHP_EOL;
var_dump($serialized);
echo PHP_EOL, PHP_EOL;

echo "CallMorph->unserialize", PHP_EOL;
$closure = $cm->unserialize($serialized);
echo $closure();

For more examples, see the example/ file in the repository.

📁 Project Structure

call-morph/
├── src/
│   └── CallMorph.php
│   └── Facades/
│       └── CallMorph.php
├── example/
│   └── script.php
├── composer.json
├── .gitignore
├── LICENSE
└── README.md

📄 License

This project is licensed under the MIT License. See the LICENSE file for more information.

👨‍💻 Author

Developed by Matheus Johann Araújo – Pernambuco, Brazil.

统计信息

  • 总下载量: 5
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固