Skip to content

phpinnacle/amridge

Repository files navigation

PHPinnacle Amridge

Latest Version on Packagist Software License Coverage Status Total Downloads

PHPinnacle Amridge is asynchronous port of Goridge protocol client.

Install

Via Composer

$ composer require phpinnacle/amridge

Basic Usage

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();
});

Testing

$ composer test

Benchmarks

$ composer bench

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages