This package is built for Embedding PHP into Golang.

Overview

GoEmPHP

This package is built for Embedding PHP into Golang.

It is easy to use:

    script = php.New()
    script.Startup()
    defer script.Close() 
    if err := script.Eval("phpinfo();"); err != nil {
        log.Fatal(err)
    }
    if err := script.Exec("foobar.php"); err != nil {
        log.Fatal(err)
    }

For more examples, please read the souce code: php_test.go.

INSTALL

The first step is downloading the package. Please note that you must specify the param -d.

$ go get -d github.com/mikespook/goemphp

Then, following step is running bootstrap.sh to prepar the embeded PHP library. It has one paramater with 4 values: [5.4 | 5.5 | 5.6 | ng]

Eg.,

./bootstrap.sh 5.6

will wget, configure and make the libphp5.so file which can be used for embedding PHP.

It will be a long time waiting. When you see Congratulations!!!, it means you have already got the proper .so file placed in ./php-lib/libs/. You could check it manually.

The third step is calling go generate to prepare source files which will be built.

If generate process do not report any issue, then you could call go build to build GoEmPHP.

After that, please use ./test.sh for testing the package. And of course, you could run go test -ldflags="-r ./php-lib/libs/" manually, or put the .so into one of system library directories and run go test. The same library mechanism should be used when you use this library in your application.

Contacts

Open Source

See LICENSE for more information.

Comments
  • Can I compile output as standalone and portable.

    Can I compile output as standalone and portable.

    Dear Mikespook

    Goemphp is good idea. But when i'm running output binary file on another system. It's failed to run. I want to make portable and standalone binary file. Is it possible or not?

    opened by ghost 4
  • Sessions with embedded PHP

    Sessions with embedded PHP

    I'm having issues with starting sessions with the library... C is not my strongsuit so I hope you could help me with this... With a php script like this <?php session_start();

    It always gives me:

    Warning: session_start(): Cannot send session cookie - headers already sent in /vagrant/go_php/public/index.php on line 2

    Call Stack: 0.0028 220704 1. {main}() /vagrant/go_php/public/index.php:0 0.0028 220752 2. session_start() /vagrant/go_php/public/index.php:2

    Warning: session_start(): Cannot send session cache limiter - headers already sent in /vagrant/go_php/public/index.php on line 2

    Call Stack: 0.0028 220704 1. {main}() /vagrant/go_php/public/index.php:0 0.0028 220752 2. session_start() /vagrant/go_php/public/index.php:2

    2014/09/03 18:05:06 session_start(): Cannot send session cache limiter - headers already sent exit status 1

    bug 
    opened by mvmaasakkers 2
  • Failed to install

    Failed to install

    I got this below error when I'm running this command

    Command: go get github.com/mikespook/goemphp/php

    Error:

    # github.com/mikespook/goemphp/php
    GoLang/src/github.com/mikespook/goemphp/php/php.go:9:19: fatal error: zend.h: No such file or directory
     // #include "zend.h"
                       ^
    compilation terminated.
    
    opened by ghost 2
  • Headers in PHP in  with embedded PHP

    Headers in PHP in with embedded PHP

    If the php send a header for 302 , 301 , 404 in php script , and the golang project is a web project , the golang project need send the header to the web also . thanks .

    opened by xulei8 0
  • output redirecting

    output redirecting

    We should not use syscall for redirecting output, otherwise it will affect whole app's output. There should be a way which can manipulate PHP stdout/stderr in C.

    opened by mikespook 0
  • can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB)

    can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB)

    trying to compile this package against php version 5.4.15, custom build on a Mac OS X 10.7.5 gcc version 4.2.1

    gcc -I . -g -O2 -fPIC -m64 -pthread -fno-common -o $WORK/github.com/mikespook/goemphp/php/_obj/_cgo_.o $WORK/github.com/mikespook/goemphp/php/_obj/_cgo_main.o $WORK/github.com/mikespook/goemphp/php/_obj/_cgo_export.o $WORK/github.com/mikespook/goemphp/php/_obj/php.cgo2.o $WORK/github.com/mikespook/goemphp/php/_obj/php_embed.o -lphp5
    # github.com/mikespook/goemphp/php
    
    ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) for architecture x86_64
    collect2: ld returned 1 exit status
    
    bug 
    opened by wstucco 0
Owner
Xing
Xing
BfInterpreterGo - Brainfuck interpreter built in golang

bfInterpreterGo Brainfuck interpreter built in golang. Usage main.exe --filename

voviner 1 Jan 7, 2022
WindLang, A simple programming language built with golang 🍃

WindLang, A simple programming language built with golang ?? WindLang, A simple programming language built with golang ?? What is wind? Playground Coo

null 8 May 23, 2022
a dynamically typed, garbage collected, embeddable programming language built with Go

The agora programming language Agora is a dynamically typed, garbage collected, embeddable programming language. It is built with the Go programming l

Martin Angers 324 Sep 10, 2022
Weave Ignite is an open source Virtual Machine (VM) manager with a container UX and built-in GitOps management.

Weave Ignite is an open source Virtual Machine (VM) manager with a container UX and built-in GitOps management.

Temur Yunusov 0 Nov 16, 2021
DEPRECATED. Embeds mruby (mini Ruby) VM into Go.

GoMRuby Package gomruby embeds mruby (mini Ruby) VM into Go. Documentation. Installation It's slightly more than just go get: go get -d github.com/Ale

Alexey Palazhchenko 23 May 17, 2022
Compiler for a small language into x86-64 Assembly

Compiler This project is a small compiler, that compiles my own little language into X86-64 Assembly. It then uses yasm and ld to assemble and link in

Maurice Tollmien 241 Aug 8, 2022
Scriptable interpreter written in golang

Anko Anko is a scriptable interpreter written in Go. (Picture licensed under CC BY-SA 3.0, photo by Ocdp) Usage Example - Embedded package main impor

mattn 1.3k Sep 20, 2022
A bytecode-based virtual machine to implement scripting/filtering support in your golang project.

eval-filter Implementation Scripting Facilities Types Built-In Functions Conditionals Loops Functions Case/Switch Use Cases Security Denial of service

Steve Kemp 85 Aug 29, 2022
Gentee - script programming language for automation. It uses VM and compiler written in Go (Golang).

Gentee script programming language Gentee is a free open source script programming language. The Gentee programming language is designed to create scr

Alexey Krivonogov 99 Sep 26, 2022
A BASIC interpreter written in golang.

05 PRINT "Index" 10 PRINT "GOBASIC!" 20 PRINT "Limitations" Arrays Line Numbers IF Statement DATA / READ Statements Builtin Functions Types 30 PRINT "

Steve Kemp 282 Aug 20, 2022
v8 javascript engine binding for golang

Go-V8 V8 JavaScript engine bindings for Go. Features Thread safe Thorough and careful testing Boolean, Number, String, Object, Array, Regexp, Function

Hoping White 206 Sep 14, 2022
A simple virtual machine - compiler & interpreter - written in golang

go.vm Installation Build without Go Modules (Go before 1.11) Build with Go Modules (Go 1.11 or higher) Usage Opcodes Notes The compiler The interprete

Steve Kemp 241 Sep 23, 2022
A JavaScript interpreter in Go (golang)

otto -- import "github.com/robertkrimen/otto" Package otto is a JavaScript parser and interpreter written natively in Go. http://godoc.org/github.com/

Robert Krimen 6.9k Sep 27, 2022
Genetic Algorithms library written in Go / golang

Description Genetic Algorithms for Go/Golang Install $ go install git://github.com/thoj/go-galib.git Compiling examples: $ git clone git://github.com

Thomas Jager 192 May 26, 2022
Monitorable, gracefully restarting, self-upgrading binaries in Go (golang)

overseer overseer is a package for creating monitorable, gracefully restarting, self-upgrading binaries in Go (golang). The main goal of this project

Jaime Pillora 1.9k Sep 28, 2022
This is a Virtual Operating System made by using GOLANG and FYNE.

Virtual-Operating-System This is a Virtual Operating System made by using GOLANG and FYNE. Hello! All In this project I have made a virtual Operating

SURBHI SINHA 1 Nov 1, 2021
Virtual Operating System Using Golang

Virtual Operating System Virtual Operating System Using Golang And Fyne Installation 1.Install Go 2.Install Gcc 3.Install Fyne Using This Command:- g

Ranjit Kumar Sahoo 2 Jun 5, 2022
Curry é um crawler escrito em Golang com a finalidade de verificar o valor do câmbio de USD(Dólar) x BRL(Real) em lojas no Paraguay.

?? Curry - Câmbios ?? Valor do câmbio(USDxBRL) em lojas no Paraguay ?? Sobre Curry é um WebCrawler escrito em Golang com finalidade de verificar os va

bitebait 2 Aug 30, 2022
interpreter for the basic language written in golang

jirachi interpreter for the basic language written in golang The plan supports the following functions: Arithmetic Operations (+, -, *, /, ^) Comparis

菜菜 6 Sep 17, 2022