Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

Serializable Closure

Build Status Total Downloads Latest Stable Version License

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.x series 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.

关于 About

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

语言 Languages

PHP100.0%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
37
Total Commits
峰值: 7次/周
Less
More

核心贡献者 Contributors