Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

laravel/serializable-closure

Build StatusTotal DownloadsLatest Stable VersionLicense

Introduction

This project is a fork of the excellentopis/closure: 3.x package. At Laravel, we decided to fork this package as the upcoming version4.x is a complete rewrite on top of theFFI extension. As Laravel is a web framework, and FFI is not enabled by default in web requests, this fork allows us to keep using the3.x series while adding support for new PHP versions.

Laravel Serializable Closure provides an easy and secure way toserialize closures in PHP.

Official Documentation

Installation

RequiresPHP 7.4+

First, install Laravel Serializable Closure via theComposer package manager:

composer require laravel/serializable-closure

Usage

You may serialize a closure this way:

useLaravel\SerializableClosure\SerializableClosure;$closure =fn () =>'james';// RecommendedSerializableClosure::setSecretKey('secret');$serialized =serialize(newSerializableClosure($closure));$closure =unserialize($serialized)->getClosure();echo$closure();// james;

Caveats

  • Anonymous classes cannot be created within closures.
  • Attributes cannot be used within closures.
  • Serializing closures on REPL environments like Laravel Tinker is not supported.
  • Serializing closures that reference objects with readonly properties is not supported.

Contributing

Thank you for considering contributing to Serializable Closure! The contribution guide can be found in theLaravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by theCode of Conduct.

Security Vulnerabilities

Please reviewour security policy on how to report security vulnerabilities.

License

Serializable Closure is open-sourced software licensed under theMIT license.

About

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

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors19

Languages


[8]ページ先頭

©2009-2025 Movatter.jp