Write PHP extension using go/golang. Zend API wrapper for go/golang.
Simple, easy, fun to write PHP extensions.
- 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
- Modern Linux/Unix system
- PHP 5.5+/7.x
- go version 1.4+
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.
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)
}
- install with go get
- improve php7 support
- namespace support
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request