{"id":17362757,"url":"https://github.com/trim21/go-phpserialize","last_synced_at":"2025-03-16T04:30:55.338Z","repository":{"id":41431973,"uuid":"509281972","full_name":"trim21/go-phpserialize","owner":"trim21","description":"PHP `serialize` and `unserialize` in Golang","archived":false,"fork":false,"pushed_at":"2025-02-13T07:06:58.000Z","size":439,"stargazers_count":17,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-15T23:24:45.351Z","etag":null,"topics":["decoding","encoding","go","golang","php","phpserialize","phpunserialize","serialize","unserialize"],"latest_commit_sha":null,"homepage":"","language":"Go","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/trim21.png","metadata":{"files":{"readme":"readme.md","changelog":null,"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}},"created_at":"2022-07-01T01:22:21.000Z","updated_at":"2025-03-04T15:49:03.000Z","dependencies_parsed_at":"2024-10-18T01:14:10.411Z","dependency_job_id":null,"html_url":"https://github.com/trim21/go-phpserialize","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trim21%2Fgo-phpserialize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trim21%2Fgo-phpserialize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trim21%2Fgo-phpserialize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trim21%2Fgo-phpserialize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trim21","download_url":"https://codeload.github.com/trim21/go-phpserialize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826788,"owners_count":20354220,"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":["decoding","encoding","go","golang","php","phpserialize","phpunserialize","serialize","unserialize"],"created_at":"2024-10-15T19:42:33.632Z","updated_at":"2025-03-16T04:30:55.332Z","avatar_url":"https://github.com/trim21.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-phpserialize\n\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/trim21/go-phpserialize?style=flat-square)\n[![Go Reference](https://pkg.go.dev/badge/github.com/trim21/go-phpserialize#section-readme.svg)](https://pkg.go.dev/github.com/trim21/go-phpserialize#section-readme)\n\nPHP `serialize()` and `unserialize()` for Go.\n\nSupport All go type including `map`, `slice`, `struct`, `array`, and simple type like `int`, `uint` ...etc.\n\nEncoding and decoding some type from standard library like `time.Time`, `net.IP` are not supported.\nIf you have any thought about how to support these types, please create an issue.\n\nOr you can wrap these types and implement `phpserialize.Marshaler` or `phpserialize.Unmarshaler`\n\n## Supported and tested go version\n\n- 1.20\n- 1.21\n- 1.22\n- 1.23\n- 1.24\n\n## Install\n\n```console\ngo get github.com/trim21/go-phpserialize\n```\n\n## Usage\n\nSee [examples](./example_test.go)\n\n### Marshal\n\nStruct and map will be encoded to php array only.\n\n### Unmarshal\n\nDecoding from php serialized array, class or object are all supported.\n\ngo `any` type will be decoded as `map[any]any` or `map[string]any`, based on raw input is `array` or `class`,\n\nkeys of `map[any]any` maybe `int64` or `string`.\n\n## Note\n\ngo `reflect` package allow you to create dynamic struct with [reflect.StructOf](https://pkg.go.dev/reflect#StructOf),\nbut please use it with caution.\n\nFor performance, this package will try to \"compile\" input type to a static encoder/decoder\nat first time and cache it for future use.\n\nSo a dynamic struct may cause memory leak.\n\n## Changelog\n\n### v0.1.0\n\nAdd new `Marshaler` to match `json.Marshaler`.\n\nGo 1.23 has decided to [lock down future uses of `//go:linkname`](https://github.com/golang/go/issues/67401),\nSo we did a major refactoring in v0.1.0.\nFor simplicity, support for embed struct has been removed,\nif you need this feature, send a Pull Request.\n\n## Security\n\nTL;DR: Don't unmarshal content you can't trust.\n\nAttackers may consume large memory with very few bytes.\n\nphp serialized array has a length prefix `a:1:{i:0;s:3:\"one\";}`, when decoding php serialized array into go `slice` or\ngo `map`,\n`go-phpserialize` may call golang's `make()` to create a map or slice with given length.\n\nSo a malicious input like `a:100000000:{}` may become `make([]T, 100000000)` and consume high memory.\n\nIf you have to decode some un-trusted bytes, make sure only decode them into fixed-length golang array or struct,\nnever decode them to `interface`, `slice` or `map`.\n\n## License\n\nMIT License\n\nHeavily inspired by https://github.com/goccy/go-json\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrim21%2Fgo-phpserialize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrim21%2Fgo-phpserialize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrim21%2Fgo-phpserialize/lists"}