Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. go-php

go-php

MITGo0.11.0

PHP bindings for Go that enable executing PHP scripts, exchanging variables, and attaching Go methods as PHP classes.

GitHubGitHub
943 stars106 forks0 contributors

What is go-php?

Go-PHP is a Go package that provides bindings for executing PHP scripts within Go applications. It allows developers to run PHP code, exchange variables between Go and PHP contexts, and attach Go methods as PHP classes. This enables integration of PHP functionality into Go-based systems without requiring separate PHP runtime environments.

Target Audience

Go developers who need to integrate existing PHP codebases, scripts, or libraries into their Go applications, particularly those migrating from PHP to Go or building polyglot systems.

Value Proposition

Developers choose Go-PHP because it provides a straightforward way to execute PHP code from Go with bidirectional variable exchange and class attachment capabilities, avoiding the need for external PHP processes or complex interoperability layers.

Overview

PHP bindings for the Go programming language (Golang)

Use Cases

Best For

  • Integrating legacy PHP scripts into modern Go applications
  • Executing PHP templating engines from Go web servers
  • Building Go applications that need to call PHP libraries or functions
  • Migrating PHP codebases to Go incrementally
  • Creating polyglot systems that combine Go performance with PHP functionality
  • Embedding PHP execution in Go CLI tools or services

Not Ideal For

  • High-throughput concurrent applications using goroutines, due to PHP's lack of thread-safety without ZTS support
  • Projects requiring the latest PHP 8.x features, as support is limited to PHP 5.x and 7.x series
  • Teams seeking a plug-and-play solution without system dependencies, since building requires PHP installed as a library (e.g., php-embed)

Pros & Cons

Pros

Bidirectional Variable Exchange

Allows binding Go variables to PHP contexts and returning PHP values to Go via Context.Bind and Context.Eval, enabling seamless data flow between languages without external processes.

Method Receiver Attachment

Supports attaching Go method receivers as PHP classes with NewReceiver, facilitating object-oriented interoperability by exposing exported methods and embedded struct fields.

PHP Version Flexibility

Compatible with both PHP 5.x and 7.x series, providing practical interoperability for legacy and modern PHP codebases, as noted in the README.

Stable Script Execution

Executing PHP script files and inline strings via Context.Exec and Context.Eval is marked as stable, offering reliable integration for existing PHP scripts.

Cons

Severe Multithreading Limitations

PHP lacks thread-safety without ZTS, which is unsupported in this package, severely restricting use with goroutines and requiring careful context management, as admitted in the Caveats section.

Sparse Documentation

The Roadmap explicitly states a lack of documentation and examples, making implementation and debugging more challenging for developers.

Complex Build Setup

Requires PHP installed as a library (e.g., php-embed), adding system dependencies and build complexity, especially with version-specific tags like 'php5' for older PHP.

Frequently Asked Questions

Quick Stats

Stars943
Forks106
Contributors0
Open Issues19
Last commit1 year ago
CreatedSince 2015

Tags

#language-interop#integration#ffi#go-bindings#golang#php#polyglot#go#language-bindings

Built With

G
Go
P
PHP

Included in

Go169.1k
Auto-fetched 1 day ago

Related Projects

FrankenPHPFrankenPHP

🧟 The modern PHP app server

Stars11,295
Forks479
Last commit1 day ago
exprexpr

Expression language and expression evaluation for Go

Stars7,978
Forks525
Last commit1 month ago
gojagoja

ECMAScript/JavaScript engine in pure Go

Stars7,053
Forks465
Last commit1 day ago
gopher-luagopher-lua

GopherLua: VM and compiler for Lua in Go

Stars6,966
Forks705
Last commit4 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub