{"id":16155011,"url":"https://github.com/mweibel/php-to-go","last_synced_at":"2025-07-28T15:07:54.929Z","repository":{"id":66164537,"uuid":"122719075","full_name":"mweibel/php-to-go","owner":"mweibel","description":"Library for generating Go structs using sheriff out of PHP models which use JMS Serializer.","archived":false,"fork":false,"pushed_at":"2018-03-26T14:34:09.000Z","size":33,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-25T11:27:18.369Z","etag":null,"topics":["go","jms-serializer","json","marshalling","php","reflection"],"latest_commit_sha":null,"homepage":"","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/mweibel.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":"2018-02-24T08:15:22.000Z","updated_at":"2023-10-20T19:48:18.000Z","dependencies_parsed_at":"2023-04-05T11:16:49.809Z","dependency_job_id":null,"html_url":"https://github.com/mweibel/php-to-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mweibel/php-to-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mweibel%2Fphp-to-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mweibel%2Fphp-to-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mweibel%2Fphp-to-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mweibel%2Fphp-to-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mweibel","download_url":"https://codeload.github.com/mweibel/php-to-go/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mweibel%2Fphp-to-go/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267534874,"owners_count":24103189,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","jms-serializer","json","marshalling","php","reflection"],"created_at":"2024-10-10T01:19:28.679Z","updated_at":"2025-07-28T15:07:54.866Z","avatar_url":"https://github.com/mweibel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-to-go\n[![Build Status](https://travis-ci.org/mweibel/php-to-go.svg?branch=master)](https://travis-ci.org/mweibel/php-to-go)\n[![Coverage Status](https://coveralls.io/repos/github/mweibel/php-to-go/badge.svg?branch=master)](https://coveralls.io/github/mweibel/php-to-go?branch=master)\n\nLibrary for generating Go structs using [sheriff](https://github.com/liip/sheriff) out of PHP models which use [JMS Serializer](https://jmsyst.com/libs/serializer).\n\n## Status\n\nAlpha.\n\nHas not been tested in real production workload yet. Has been tested locally against a test system using big models and quite some data.\n\nDocumentation of what it does should become better too.\n\n## Contributions\n\nContributions in any form are welcome. \nI try to keep this library as small as possible. If you plan a big PR it might be better to ask first in an issue.\n\nIf you change PHP code please ensure to accompany it with an automated test.\n\n## Why\n\nCan be used to turn an existing serialization solution using PHP and JMS Serializer into one based on Go and sheriff.\n\n## How\n\n```php\n\u003c?php\n// where to find your models\n$srcGlob = './models/*.php';\n// target directory of your Go files. Needs to be within $GOPATH.\n$targetDirectory = getenv('GOPATH').'/src/github.com/mweibel/php-to-go-tests';\n// package name of the Go structs\n$packageName = 'models';\n// list of ignored files within the target directory\n$ignoredFiles = [];\n// list of ignored property names (in case some are misbehaving or so)\n$ignoredPropertyNames = [];\n// echo what is being done\n$verbose = true;\n\n$generator = new PHPToGo\\CodeGenerator($srcGlob, $targetDirectory, $packageName, $ignoredFiles, $ignoredPropertyNames, $verbose);\n$generator-\u003egenerate();\n```\n\nThe generated files can then be incorporated into any Go program.\n\nThe code generator detects if there are methods annotated using `VirtualProperty`. \nIn this case the generated model needs an AfterMarshal function receiver on that type.\nAs the code generator will overwrite the files it generated (on repeated execution), customizations to the generated types\nshould go into a separate file.\n\nExample noop `AfterMarshal` function on a type called `RootModel`:\n\n```go\npackage models\n\nimport \"github.com/liip/sheriff\"\n\nfunc (rm RootModel) AfterMarshal(options *sheriff.Options, data interface{}) (interface{}, error) {\n\treturn data, nil\n}\n``` \n\nIf you want to interface with existing PHP code you can use e.g. [goridge](https://github.com/spiral/goridge).\n\n# License\n\nMIT (see LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmweibel%2Fphp-to-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmweibel%2Fphp-to-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmweibel%2Fphp-to-go/lists"}