PHPinnacle Amridge is asynchronous port of Goridge protocol client.
Via Composer
$ composer require phpinnacle/amridge
Simple Golang RPC Echo server:
package main
import (
"fmt"
"github.com/spiral/goridge"
"log"
"net"
"net/rpc"
)
type App struct{}
func (a *App) Hi(text string, r *string) error {
*r = fmt.Sprintf(text)
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))
}
}
And PHP client:
<?php
use Amp\Loop;
use PHPinnacle\Amridge\RPC;
require __DIR__ . '/vendor/autoload.php';
Loop::run(function () {
/** @var RPC $rpc */
$rpc = yield RPC::connect('tcp://127.0.0.1:6001');
echo yield $rpc->call("App.Hi", "Hello from async PHP to Golang!");
$rpc->disconnect();
});
$ composer test
$ composer bench
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.