laravel/serializable-closure
Composer 安装命令:
composer require laravel/serializable-closure
包简介
Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
README 文档
README
Introduction
This project is a fork of the excellent opis/closure: 3.x package. At Laravel, we decided to fork this package as the upcoming version 4.x is a complete rewrite on top of the FFI extension. As Laravel is a web framework, and FFI is not enabled by default in web requests, this fork allows us to keep using the
3.xseries while adding support for new PHP versions.
Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
Official Documentation
Installation
Requires PHP 7.4+
First, install Laravel Serializable Closure via the Composer package manager:
composer require laravel/serializable-closure
Usage
You may serialize a closure this way:
use Laravel\SerializableClosure\SerializableClosure; $closure = fn () => 'james'; // Recommended SerializableClosure::setSecretKey('secret'); $serialized = serialize(new SerializableClosure($closure)); $closure = unserialize($serialized)->getClosure(); echo $closure(); // james;
Caveats
- Serializing closures on REPL environments like Laravel Tinker is not supported.
- 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.
Contributing
Thank you for considering contributing to Serializable Closure! The contribution guide can be found in the Laravel documentation.
Code of Conduct
In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
Serializable Closure is open-sourced software licensed under the MIT license.
laravel/serializable-closure 适用场景与选型建议
laravel/serializable-closure 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 360.91M 次下载、GitHub Stars 达 604, 最近一次更新时间为 2021 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「closure」 「serializable」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 laravel/serializable-closure 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 laravel/serializable-closure 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 laravel/serializable-closure 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
LazyPDO is a set of wrappers over PHP's standard PDO and PDOStatement classes. It enables lazy loading, serialization and decoration.
Laravel Query Builder (Eloquent) serialization
Adjacency List’ed Closure Table database design pattern implementation for Laravel. Includes restore of tree
The Closure Compiler is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites an
Behavior for saving and reading serialized data from/into database
PHP client for the Google Closure Compiler API in one file.
统计信息
- 总下载量: 360.91M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 606
- 点击次数: 31
- 依赖项目数: 211
- 推荐数: 7
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-08