PHP code example of friendsofhyperf / grpc-validation
1. Go to this page and download the library: Download friendsofhyperf/grpc-validation 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/ */
friendsofhyperf / grpc-validation example snippets
declare(strict_types=1);
use FriendsOfHyperf\GrpcValidation\Annotation\Validation;
final class GreeterService
{
#[Validation(
rules: [
'name' => 'tion sayHello(HiUser $user): HiReply
{
$reply = new HiReply();
$reply->setMessage('Hello World');
$reply->setUser($user);
return $reply;
}
}
use App\Request\SayHelloRequest;
use FriendsOfHyperf\GrpcValidation\Annotation\Validation;
final class GreeterService
{
#[Validation(formRequest: SayHelloRequest::class, scene: 'create')]
public function sayHello(HiUser $user): HiReply
{
// ...
}
}