{"id":19737108,"url":"https://github.com/arnaud-lb/php-go","last_synced_at":"2025-04-30T04:33:06.564Z","repository":{"id":66284396,"uuid":"48624970","full_name":"arnaud-lb/php-go","owner":"arnaud-lb","description":"php-go allows to call Go code from PHP, with minimal code boilerplate","archived":false,"fork":false,"pushed_at":"2020-07-29T04:25:07.000Z","size":61,"stargazers_count":186,"open_issues_count":7,"forks_count":19,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-06-20T10:12:50.586Z","etag":null,"topics":["go","golang","php","php-go"],"latest_commit_sha":null,"homepage":"","language":"C","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/arnaud-lb.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":"2015-12-26T22:09:00.000Z","updated_at":"2024-06-03T01:57:43.000Z","dependencies_parsed_at":"2023-03-18T09:32:24.545Z","dependency_job_id":null,"html_url":"https://github.com/arnaud-lb/php-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaud-lb%2Fphp-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaud-lb%2Fphp-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaud-lb%2Fphp-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaud-lb%2Fphp-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnaud-lb","download_url":"https://codeload.github.com/arnaud-lb/php-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224197917,"owners_count":17271999,"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":["go","golang","php","php-go"],"created_at":"2024-11-12T01:09:43.834Z","updated_at":"2024-11-12T01:09:44.395Z","avatar_url":"https://github.com/arnaud-lb.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php-go\n\n![Supported PHP versions: 7.x](https://img.shields.io/badge/php-7.x-blue.svg) [![Build Status](https://travis-ci.org/arnaud-lb/php-go.svg)](https://travis-ci.org/arnaud-lb/php-go)\n\nphp-go allows to call Go code from PHP, with minimal code boilerplate.\n\n## Goals:\n\n- Allow to _export_ Go functions and Go constants from Go to PHP\n- Be reliable and always safe\n- Deploy Go code without re-building the PHP extension\n\n## TODO:\n\n- [x] Support exporting functions\n- [x] Support all scalar types in arguments and return values\n- [ ] Support exporting constants\n- [ ] Support slices, maps (copying)\n- [ ] Support objects (proxying)\n\n## Install\n\nYou can download this package using \"go get\". When using \"go get\", you'll have to [set your $GOPATH](https://github.com/golang/go/wiki/SettingGOPATH) first.\nThen you can run:\n\n```\ngo get github.com/arnaud-lb/php-go\n```\n\nWhen this is finished, change directories to the included \"ext\" folder:\n\n```\ncd $GOPATH/src/github.com/arnaud-lb/php-go/ext\n```\n\nThen configure and make the binary:\n\n```\nphpize \u0026\u0026 ./configure \u0026\u0026 make \u0026\u0026 sudo make install\n```\n\nThen add ``extension=phpgo.so`` to your php.ini, or call php with ``-dextension=phpgo.so``\n\nNote: php-go supports PHP 7 (non-ZTS). For PHP 5, use the php5 branch.\n\n## Usage\n\n#### Exporting Go functions\n\n``` go\npackage main\n\nimport (\n  \"strings\"\n  \"github.com/arnaud-lb/php-go/php-go\"\n)\n\n// call php.Export() for its side effects\nvar _ = php.Export(\"example\", map[string]interface{}{\n  \"toUpper\": strings.ToUpper,\n  \"takeOverTheWorld\": TakeOverTheWorld,\n})\n\nfunc TakeOverTheWorld() {\n}\n\nfunc main() {\n}\n```\n\nThe module can then be compiled as a shared library using `-buildmode c-shared`:\n\n    go build -o example.so -buildmode c-shared .\n\nNote: Go **requires** that the module be a _main_ package with a _main_ function in this mode.\n\n#### Using the module in PHP\n\n``` php\n// Create a class from the Go module, and return an instance of it\n$module = phpgo_load(\"/path/to/example.so\", \"example\");\n\n// Display the methods defined by the class\nReflectionClass::export($module);\n\n// Call some method\n$module-\u003etoUpper(\"foo\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaud-lb%2Fphp-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnaud-lb%2Fphp-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaud-lb%2Fphp-go/lists"}