PHP bindings for Go that enable executing PHP scripts, exchanging variables, and attaching Go methods as PHP classes.
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.
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.
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.
PHP bindings for the Go programming language (Golang)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
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.
Supports attaching Go method receivers as PHP classes with NewReceiver, facilitating object-oriented interoperability by exposing exported methods and embedded struct fields.
Compatible with both PHP 5.x and 7.x series, providing practical interoperability for legacy and modern PHP codebases, as noted in the README.
Executing PHP script files and inline strings via Context.Exec and Context.Eval is marked as stable, offering reliable integration for existing PHP scripts.
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.
The Roadmap explicitly states a lack of documentation and examples, making implementation and debugging more challenging for developers.
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.