PHP code example of hungthai1401 / laravel-grpc-validation
1. Go to this page and download the library: Download hungthai1401/laravel-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/ */
hungthai1401 / laravel-grpc-validation example snippets
use Spiral\RoadRunner\GRPC\InvokerInterface;
$worker = Worker::create();
$invoker = $this->container->make(InvokerInterface::class);
$server = new GrpcServer($invoker);
$server->registerService(..., ...);
// The server will use the configuration from .rr.yaml or environment
$server->serve($worker);
return 0;
use HT\GrpcValidation\Validation;
use GoodByeFormRequest;
#[Validation(
rules: [
'name' => 'is ',
'message.],
attributes: [
'name' => 'Name',
'message' => 'Message',
],
)]
public function sayHello(HiUser $user)
{
$message = new HiReply();
$message->setMessage("Hello World");
$message->setUser($user);
return $message;
}
#[Validation(formRequest: GoodByeFormRequest::class)]
public function sayGoodBye(GoodByeUser $user)
{
$message = new GoodByeReply();
$message->setMessage("Goodbye World");
$message->setUser($user);
return $message;
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.