PHPackages                             schivei/php-go - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. schivei/php-go

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

schivei/php-go
==============

php-go allows to call Go code from PHP, with minimal code boilerplate.

1.0.0(2y ago)6312MITCPHP &gt;=8.0

Since Feb 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/schivei/php-go)[ Packagist](https://packagist.org/packages/schivei/php-go)[ RSS](/packages/schivei-php-go/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

php-go
======

[](#php-go)

php-go allows to call Go code from PHP, with minimal code boilerplate.

Goals:
------

[](#goals)

- Allow to *export* Go functions and Go constants from Go to PHP
- Be reliable and always safe
- Deploy Go code without re-building the PHP extension

DOING:
------

[](#doing)

- Support GoLang Http Requests

Install
-------

[](#install)

You can download this package using "go install". Then you can run:

```
go install github.com/schivei/php-go

```

NOTES:

- You need to have GoLang installed in your machine.
- php-go also requires PHP development headers to be installed.
- php-go needs CGO to be enabled.

When this is finished, go to your project directory and run:

```
php-go

```

You also can pass binary directory as argument:

```
php-go /path/to/bin

```

The extension will be built and placed in the current directory.

Then copy the resulting `phpgo.so` to your PHP extensions directory and add `extension=phpgo.so` to your php.ini.

Alternatively, you can use `phpgo.so` from the `bin` directory.

Note: php-go supports PHP 8+ (non-ZTS).

Also, you can use php composer to install this package:

```
composer require schivei/php-go

```

It will install the package and the extension will be placed in the `vendor/schivei/php-go` directory.

Usage
-----

[](#usage)

#### Exporting Go functions

[](#exporting-go-functions)

```
package main

import (
  "strings"
  "github.com/schivei/php-go/php"
)

// call php.Export() for its side effects
var _ = php.Export("example", map[string]interface{}{
  "toUpper": strings.ToUpper,
  "takeOverTheWorld": TakeOverTheWorld,
})

func TakeOverTheWorld() {
}

func main() {
}
```

The module can then be compiled as a shared library using `-buildmode c-shared`:

```
go build -o example.so -buildmode c-shared .

```

Note: Go **requires** that the module be a *main* package with a *main* function in this mode.

#### Using the module in PHP

[](#using-the-module-in-php)

```
// Create a class from the Go module, and return an instance of it
$module = phpgo_load("/path/to/example.so", "example");

// Call some method
$module->toUpper("foo");
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 63.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

811d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cc8a879cf7403e5f12a8702cab1570eea2600fb703c25141ae370bafbc2bf4d6?d=identicon)[schivei](/maintainers/schivei)

---

Top Contributors

[![arnaud-lb](https://avatars.githubusercontent.com/u/365207?v=4)](https://github.com/arnaud-lb "arnaud-lb (31 commits)")[![schivei](https://avatars.githubusercontent.com/u/811061?v=4)](https://github.com/schivei "schivei (10 commits)")[![sobomax](https://avatars.githubusercontent.com/u/218662?v=4)](https://github.com/sobomax "sobomax (4 commits)")[![DasJott](https://avatars.githubusercontent.com/u/6298761?v=4)](https://github.com/DasJott "DasJott (2 commits)")[![roelofjan-elsinga](https://avatars.githubusercontent.com/u/9220754?v=4)](https://github.com/roelofjan-elsinga "roelofjan-elsinga (2 commits)")

### Embed Badge

![Health badge](/badges/schivei-php-go/health.svg)

```
[![Health](https://phpackages.com/badges/schivei-php-go/health.svg)](https://phpackages.com/packages/schivei-php-go)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
