goridge

High-performance PHP-to-Golang IPC bridge

Github星跟踪图

High-performance PHP-to-Golang IPC bridge

Latest Stable Version
GoDoc
Build Status
Scrutinizer Code Quality
Go Report Card

Goridge is high performance PHP-to-Golang codec library which works over native PHP sockets and Golang net/rpc package.
The library allows you to call Go service methods from PHP with minimal footprint, structures and []byte support.

Features

  • no external dependencies or services, drop-in (64bit PHP version required)
  • low message footprint (17 bytes over any binary payload), binary error detection
  • sockets over TCP or Unix (ext-sockets is required), standard pipes
  • very fast (300k calls per second on Ryzen 1700X over 20 threads)
  • native net/rpc integration, ability to connect to existed application(s)
  • standalone protocol usage
  • structured data transfer using json
  • []byte transfer, including big payloads
  • service, message and transport level error handling
  • hackable
  • works on Windows

Installation

$ go get "github.com/spiral/goridge"
$ composer require spiral/goridge

Example

<?php
use Spiral\Goridge;
require "vendor/autoload.php";

$rpc = new Goridge\RPC(new Goridge\SocketRelay("127.0.0.1", 6001));

echo $rpc->call("App.Hi", "Antony");
package main

import (
	"fmt"
	"github.com/spiral/goridge"
	"net"
	"net/rpc"
)

type App struct{}

func (s *App) Hi(name string, r *string) error {
	*r = fmt.Sprintf("Hello, %s!", name)
	return nil
}

func main() {
	ln, err := net.Listen("tcp", ":6001")
	if err != nil {
		panic(err)
	}

	rpc.Register(new(App))

	for {
		conn, err := ln.Accept()
		if err != nil {
			continue
		}
		go rpc.ServeCodec(goridge.NewCodec(conn))
	}
}

Check this libraries in order to find suitable socket manager:

License

The MIT License (MIT). Please see LICENSE for more information.

主要指标

概览
名称与所有者roadrunner-server/goridge
主编程语言Go
编程语言Go (语言数: 3)
平台
许可证MIT License
所有者活动
创建于2017-08-13 15:34:04
推送于2025-04-25 16:31:58
最后一次提交2025-04-25 18:31:56
发布数75
最新版本名称v3.8.3 (发布于 )
第一版名称v1.0.0 (发布于 )
用户参与
星数1.3k
关注者数41
派生数77
提交数627
已启用问题?
问题数0
打开的问题数0
拉请求数93
打开的拉请求数0
关闭的拉请求数23
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?