Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kitech/php-go
Write PHP extension using go/golang. Zend API wrapper for go/golang.
https://github.com/kitech/php-go
Last synced: 2 days ago
JSON representation
Write PHP extension using go/golang. Zend API wrapper for go/golang.
- Host: GitHub
- URL: https://github.com/kitech/php-go
- Owner: kitech
- Created: 2016-05-10T04:15:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-20T04:36:21.000Z (over 5 years ago)
- Last Synced: 2024-12-14T01:08:43.485Z (9 days ago)
- Language: C
- Size: 118 KB
- Stars: 882
- Watchers: 52
- Forks: 108
- Open Issues: 25
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
- awesome-php-extensions - php-go - 用 Go 语言编写 PHP 扩展 (扩展编写)
README
[![GoDoc](https://godoc.org/github.com/kitech/php-go/phpgo?status.svg)](https://godoc.org/github.com/kitech/php-go/phpgo)
[![GoDoc](https://godoc.org/github.com/kitech/php-go/zend?status.svg)](https://godoc.org/github.com/kitech/php-go/zend)### 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 programmatic### Environment
* Modern Linux/Unix system
* PHP 5.5+/7.x
* go version 1.4+
* php5-dev installed (`apt-get install php5-dev`)
* for MacOS, go 1.8+### Build & Install
go get:
```
go get github.com/kitech/php-go
cd $GOPATH/src/github.com/kitech/php-go
# adjust PHPCFG path if needed
PHPCFG=`which php-config` make
```manual:
mkdir -p $GOPATH/src/github.com/kitech
git clone https://github.com/kitech/php-go.git $GOPATH/src/github.com/kitech/php-go
cd $GOPATH/src/github.com/kitech/php-go
make
ls -lh php-go/hello.so
php56 -d extension=./hello.so examples/hello.php### Examples
```go
// package main is required
package mainimport "github.com/kitech/php-go/phpgo"
func foo_in_go() {
}type Bar struct{}
func NewBar() *Bar{
return &Bar{}
}func init() {
phpgo.InitExtension("mymod", "1.0")phpgo.AddFunc("foo_in_php", foo_in_go)
phpgo.AddClass("bar_in_php", NewBar)
}// should not run this function
// required for go build though.
func main() { panic("wtf") }
```### Limitations
* Deadlock in pcntl_fork'ed subprocess when call extension functions. #47
### TODO
- [ ] install with go get
- [x] improve php7 support
- [ ] namespace support
- [ ] multiple extension support
- [ ] class member access support
- [x] unlimited function/method/class count support
- [x] global ini var support
- [ ] fill phpinfoContributing
------------
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