PHPackages                             sanket3dx/phpgo - 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. sanket3dx/phpgo

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

sanket3dx/phpgo
===============

True Go Concurrency for PHP - Native Extension

v1.0.1(4mo ago)80MITHTMLPHP &gt;=8.0

Since Jan 9Pushed 4mo agoCompare

[ Source](https://github.com/Sanket3dx/phpgo)[ Packagist](https://packagist.org/packages/sanket3dx/phpgo)[ RSS](/packages/sanket3dx-phpgo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

phpgo - True Go Concurrency for PHP
===================================

[](#phpgo---true-go-concurrency-for-php)

`phpgo` is a native PHP extension written in Go that brings Go's concurrency primitives to PHP. It enables parallel execution using Goroutines, Channels, WaitGroups, and Select, backed by the Go runtime.

Features
--------

[](#features)

- **Goroutines**: `phpgo\go(callable)` spawns a lightness Go thread.
- **Channels**: Buffered and unbuffered channels (`phpgo\channel`).
- **Select**: Go-style `select` statement (`phpgo\select`).
- **WaitGroup**: Synchronization primitive (`phpgo\WaitGroup`).

Requirements
------------

[](#requirements)

- PHP 8.0+
- Go 1.18+
- GCC / Clang
- **ZTS (Zend Thread Safety)** PHP build is highly recommended for stability.

Architecture
------------

[](#architecture)

`phpgo` operates by loading a Go-compiled shared object (`libphpgo.so`) into a thin C-based PHP extension (`phpgo.so`). The Go runtime manages the scheduling of goroutines and channel operations.

Installation
------------

[](#installation)

### Option 1: Using Pre-compiled Binaries (Fastest)

[](#option-1-using-pre-compiled-binaries-fastest)

1. **Download** the `phpgo.so` from the `build/` folder.
2. **Copy to Extensions**: Move `phpgo.so` to your PHP extensions directory (e.g., `/usr/lib/php/20210902/`).
3. **Enable in PHP**: Add `extension=phpgo.so` to your `php.ini`.
4. **Restart**: Restart your web server (e.g., `sudo systemctl restart php8.1-fpm`).

### Option 2: Build from Source

[](#option-2-build-from-source)

1. Clone the repository.
2. Build the Go library: ```
    go build -o go-build/libphpgo.a -buildmode=c-archive src/go/lib.go
    ```
3. Build the PHP extension: ```
    phpize
    ./configure --enable-phpgo
    make
    ```
4. Load it in PHP: ```
    php -d extension=`pwd`/modules/phpgo.so script.php
    ```

Usage
-----

[](#usage)

### Channels &amp; Goroutines

[](#channels--goroutines)

```
