Git Product home page Git Product logo

gophp_sample's Introduction

golang で php 拡張を作ってみるテスト

environment

  • CentOS release 6.7
  • PHP 7.0.1
  • go version go1.5.2 linux/amd64

build

$ phpize
$ ./configure
$ CGO_CFLAGS="-g -O0 -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -I. -DPHP_ATOM_INC \
-I./include -I./main \
-I`php-config --include-dir` \
-I`php-config --include-dir`/main \
-I`php-config --include-dir`/TSRM \
-I`php-config --include-dir`/Zend \
-I`php-config --include-dir`/ext \
-I`php-config --include-dir`/ext/date/lib \
-DHAVE_CONFIG_H -DCOMPILE_DL_GOPHP -fPIC -DPIC" \
CGO_LDFLAGS="-Wl,--export-dynamic -Wl,--unresolved-symbols=ignore-all -Wl,-z,nodelete" \
go build -p 1 -gcflags "-l" -buildmode=c-shared -o modules/gophp.so gophp.go export.go

run

$ time php -d extension=`pwd`/modules/gophp.so -r 'echo go_fib(40) . PHP_EOL;'
102334155
php -d extension=`pwd`/modules/gophp.so -r 'echo go_fib(40) . PHP_EOL;'  1.87s user 0.03s system 99% cpu 1.909 total

see also

http://www.slideshare.net/do_aki/writing-php-extensions-in-golang

gophp_sample's People

Contributors

do-aki avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.