{"id":13462123,"url":"https://github.com/opis/closure","last_synced_at":"2025-05-13T20:03:32.104Z","repository":{"id":14002364,"uuid":"16703706","full_name":"opis/closure","owner":"opis","description":"Serialize closures, anonymous classes, and arbitrary data","archived":false,"fork":false,"pushed_at":"2025-01-10T21:50:17.000Z","size":524,"stargazers_count":2532,"open_issues_count":0,"forks_count":89,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-05-06T19:51:56.968Z","etag":null,"topics":["anonymous-class-serialization","closure-serialization","data-serialization","php","serializable-closures","serialization"],"latest_commit_sha":null,"homepage":"https://opis.io/closure","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-02-10T17:49:53.000Z","updated_at":"2025-04-30T15:19:56.000Z","dependencies_parsed_at":"2024-06-18T10:37:44.424Z","dependency_job_id":"94707352-8cac-4df7-885d-fb32d3d6ec49","html_url":"https://github.com/opis/closure","commit_stats":{"total_commits":373,"total_committers":18,"mean_commits":20.72222222222222,"dds":"0.10187667560321712","last_synced_commit":"3d81e4309d2a927abbe66df935f4bb60082805ad"},"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opis%2Fclosure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opis%2Fclosure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opis%2Fclosure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opis%2Fclosure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opis","download_url":"https://codeload.github.com/opis/closure/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020473,"owners_count":22000750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anonymous-class-serialization","closure-serialization","data-serialization","php","serializable-closures","serialization"],"created_at":"2024-07-31T12:00:39.352Z","updated_at":"2025-05-13T20:03:32.074Z","avatar_url":"https://github.com/opis.png","language":"PHP","readme":"Opis Closure\n====================\n[![Tests](https://github.com/opis/closure/workflows/Tests/badge.svg)](https://github.com/opis/closure/actions)\n[![Packagist Version](https://img.shields.io/packagist/v/opis/closure?label=Version)](https://packagist.org/packages/opis/closure)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/opis/closure?label=Downloads)](https://packagist.org/packages/opis/closure)\n[![Packagist License](https://img.shields.io/packagist/l/opis/closure?color=teal\u0026label=License)](https://packagist.org/packages/opis/closure)\n\nSerialize closures, serialize anything\n------------------\n\n**Opis Closure** is a PHP library that allows you to serialize closures, anonymous classes, and arbitrary data.\n\n```php\nuse function Opis\\Closure\\{serialize, unserialize};\n\n$serialized = serialize(fn() =\u003e \"hello from closure!\");\n$greet = unserialize($serialized);\n\necho $greet(); // hello from closure!\n```\n\n\u003e [!IMPORTANT]\n\u003e Starting with version 4.2, **Opis Closure** supports serialization of anonymous classes.\n\n```php\nuse function Opis\\Closure\\{serialize, unserialize};\n\n$serialized = serialize(new class(\"hello from anonymous class!\") {\n    public function __construct(private string $message) {}\n    \n    public function greet(): string {\n        return $this-\u003emessage;\n    }\n});\n\n$object = unserialize($serialized);\necho $object-\u003egreet(); // hello from anonymous class!\n```\n\n_A full rewrite was necessary to keep this project compatible with the PHP's new features, such as attributes, enums, \nread-only properties, named parameters, anonymous classes, and so on. This wasn't an easy task, as the latest attempt \nto launch a 4.x version involved using the FFI extension in exotic ways, and it failed hard. The main problem was that \nvery often the closures were bound to some object, thus in order to preserve functionality, we had to serialize the object \ntoo. Since we had to do arbitrary data serialization, we decided to make this project about arbitrary data serialization, \nproviding support for serializing closures but also adding more effortless ways to serialize custom objects._\n\n## Migrating from 3.x\n\nVersion 4.x is a full rewrite of the library, but data deserialization from 3.x is possible.\nRead the docs on [how to migrate from 3.x][migration].\n\n## Documentation\n\nThe full documentation for this library can be found [here][documentation].\n\n## License\n\n**Opis Closure** is licensed under the [MIT License (MIT)][license].\n\n## Requirements\n\n* PHP \u003e= 8.0\n\n## Installation\n\n**Opis Closure** is available on [Packagist], and it can be installed from a \ncommand line interface by using [Composer]: \n\n```bash\ncomposer require opis/closure\n```\n\nOr you could directly reference it into your `composer.json` file as a dependency\n\n```json\n{\n    \"require\": {\n        \"opis/closure\": \"^4.3\"\n    }\n}\n```\n\n[documentation]: https://opis.io/closure/4.x/ \"Opis Closure Documentation\"\n[migration]: https://opis.io/closure/4.x/migrate.html \"Opis Closure Migration guide\"\n[license]: http://opensource.org/licenses/MIT \"MIT License\"\n[Packagist]: https://packagist.org/packages/opis/closure \"Packagist\"\n[Composer]: https://getcomposer.org \"Composer\"\n[CHANGELOG]: https://github.com/opis/closure/blob/master/CHANGELOG.md \"Changelog\"\n","funding_links":[],"categories":["PHP","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopis%2Fclosure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopis%2Fclosure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopis%2Fclosure/lists"}