PHP code example of mix / grpc-skeleton

1. Go to this page and download the library: Download mix/grpc-skeleton library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mix / grpc-skeleton example snippets




namespace App\Service;

use Mix\Grpc\Context;
use Php\Micro\Grpc\Greeter\Request;
use Php\Micro\Grpc\Greeter\Response;

/**
 * Class Say
 * @package App\Service
 */
class Say implements \Php\Micro\Grpc\Greeter\SayInterface
{

    /**
     * @param Context $context
     * @param Request $request
     * @return Response
     */
    public function Hello(Context $context, Request $request): Response
    {
        $response = new Response();
        $response->setMsg(sprintf('hello, %s', $request->getName()));
        return $response;
    }

}

$server->register(Say::class);
json
"scripts": {
    "swoole:start": "php bin/swoole.php",
    "swooleco:start": "php bin/swooleco.php",
    "cli:clearcache": "php bin/cli.php clearcache"
}

php bin/swoole.php start

protoc --php_out=. --mix_out=. greeter.proto