4 Star 7 Fork 4

kitech / php-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

php-go

Write PHP extension using go/golang. Zend API wrapper for go/golang.

Simple, easy, fun to write PHP extensions.

Features

  • function support
  • struct/class support
  • constant support
  • primitive data type as parameters and return values, (u)int*/float*/string/bool
  • complex data type as parameters, map/slice/array
  • all can be done by programitic

Environment

  • Modern Linux/Unix system
  • PHP 5.5+/7.x
  • go version 1.4+

Build & Install

go get:

coming soon

mannual:

cd $GOPATH/src/
git clone https://github.com/kitech/php-go.git
ln -s php-go/zend ./
ln -s php-go/phpgo ./
make -C php-go/
ls -lh php-go/hello.so
php56 -d extension=php-go/hello.so php-go/examples/hello.php

note: php7 support not complete, use php5 for test.

Examples

import "phpgo"

func module_startup(ptype int, module_number int) int {
    return 0
}
func module_shutdown(ptype int, module_number int) int {
    return 0
}
func request_startup(ptype int, module_number int) int {
    return 0
}
func request_shutdown(ptype int, module_number int) int {
    return 0
}

function foo_in_go() {
}

type Bar struct{}
func NewBar() *Bar{
    return &Bar{}
}

func init() {
    phpgo.InitExtension("mymod", "1.0")
    phpgo.RegisterInitFunctions(module_startup, module_shutdown, request_startup, request_shutdown)
    
    phpgo.AddFunc("foo_in_php", foo_in_go)
    phpgo.AddClass("bar_in_php", NewBar)
}

TODO

  • install with go get
  • improve php7 support
  • namespace support

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

空文件

简介

Write PHP extension using go/golang. Zend API wrapper for go/golang. 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/kitech/php-go.git
git@gitee.com:kitech/php-go.git
kitech
php-go
php-go
master

搜索帮助