• Stars
    star
    882
  • Rank 51,404 (Top 2 %)
  • Language
    C
  • Created over 8 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

GoDoc GoDoc

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

// package main is required
package main

import "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
  • improve php7 support
  • namespace support
  • multiple extension support
  • class member access support
  • unlimited function/method/class count support
  • global ini var support
  • fill phpinfo

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

More Repositories

1

qt.go

Qt binding for Go (Golang) aims get Go's compile speed again.
Go
551
star
2

wxagent

A Linux weixin agent daemon based on web weixin API.
Python
75
star
3

cygo

A toy programming language base on Golang and compile to C, no name yet
Go
36
star
4

qt.rs

Qt5 binding for rust language. (stalled)
Rust
35
star
5

ruby-jit-qt

A Qt5 binding for Ruby language. Using clang/llvm JIT engine. (stalled)
C++
12
star
6

qt.inline

Qt5 C wrapper for FFI invoke original used in https://github.com/kitech/qt.go
C++
10
star
7

goplusplus

go++, golang++, goplusplus. Make golang more featureful.
Go
10
star
8

mwget

multi thread wget like command line tool
C++
9
star
9

android-nmp

android nignx mysql/sqlite php
C
8
star
10

parallel-ssh

little modified from original parallel-ssh for suite my work needs;
Python
5
star
11

kitphone

skype/sip cluster
C++
4
star
12

nullfxp

C
4
star
13

qt.gen

Go
3
star
14

triline

some little scripts for linux
Emacs Lisp
3
star
15

larbin

fork from original larbin.sf.net for custom develop
C
3
star
16

mod_authnz_external

Authentication via ACM class LDAP
C
2
star
17

snsnotify

snsnotify
C++
2
star
18

go-plugin

Unloadable Golang plugin system over CGO.
2
star
19

vmware-modules

arch linux newest vmware modules pkgbuild and patches
C
2
star
20

godsts

try make emirpasic/gods thread safe
Go
2
star
21

tinycc

Fork of https://repo.or.cz/tinycc.git
C
1
star
22

nullget

1
star
23

algosets

Some algorithm study implmention collections.
C++
1
star
24

lang-binary-size

Programming language binary size compare
Go
1
star
25

qalife

C++
1
star
26

cms-drupal

PHP
1
star
27

gearmand

在阅读代码过程中,为了方便理解,添加的一些启发性注释。
C++
1
star
28

cosp-android-ffmpeg

C
1
star
29

konsole

一个能记录会话的konsole和自动登陆的konsole版本
C++
1
star
30

congo

Go code compile to C, with an generic Go core features (goroutine,channel,defer,GC)
1
star
31

karia2

C++
1
star
32

gearman-cgo

gearman-cgo
Go
1
star
33

minqt4go

C++
1
star