Skip to content

v6.4.3

Latest
Compare
Choose a tag to compare
@sagittaracc sagittaracc released this 19 Nov 16:45
· 1 commit to main since this release
  • add Rpc
use Sagittaracc\PhpPythonDecorator\Decorator;
use Sagittaracc\PhpPythonDecorator\modules\rpc\core\Rpc;

#[Rpc]
class Controller
{
    use Decorator;

    public function sum($a, $b)
    {
        return $a + $b;
    }
}

in index.php

$requestBody = file_get_contents('php://input');

$controller = new Controller();
$controller($requestBody);

in terminal

$ curl -d "{"id":1,"method":"sum","params":[1,4]}" http://localhost:4000
{"json-rpc":"2.0","id":1,"result":5}