Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haskel/grpc-web-bundle
gRPC-Web Symfony Bundle
https://github.com/haskel/grpc-web-bundle
grpc grpc-web symfony symfony-bundle
Last synced: about 4 hours ago
JSON representation
gRPC-Web Symfony Bundle
- Host: GitHub
- URL: https://github.com/haskel/grpc-web-bundle
- Owner: haskel
- License: mit
- Created: 2023-02-11T13:18:21.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-18T18:49:56.000Z (about 1 year ago)
- Last Synced: 2024-10-13T04:23:00.991Z (about 1 month ago)
- Topics: grpc, grpc-web, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 26.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
- Security: Security/DefaultJwtCookieBuilder.php
Awesome Lists containing this project
README
## gRPC-Web Bundle
### Installation
```bash
composer require haskel/grpc-web-bundle
```Add bundle to `config/bundles.php`:
```php
return [
// ...
Haskel\GrpcWebBundle\GrpcWebBundle::class => ['all' => true],
];
```### Configuration
```yaml
# config/packages/grpc_web.yamlgrpc_web:
# optional namespace of proto files
proto_namespace: 'my.somenamespace.api'# optional name of response type attribute in request object
response_type_attribute_name: '_grpc_response_type'
# map of exception classes to grpc standard response codes
exception_code_map:
App\Exception\ValidationException: 1
App\Exception\InvalidArgumentException: 2
# configuration of integration with lexik_jwt_authentication bundle
security:
# optional class of success response builder
success_response_builder: 'App\Security\SuccessResponseBuilder'
# optional class of failure response builder
failure_response_builder: 'App\Security\FailureResponseBuilder'
# required class of sign in request
sign_in_request_class: 'App\Model\Api\SignInRequest'
```### Usage
#### Create proto file
```protobuf
syntax = "proto3";package grpc.api;
service PingService {
rpc Ping (PingRequest) returns (PingResponse) {}
}message PingRequest {
string message = 1;
}message PingResponse {
string message = 1;
}
```#### Generate php code
```bash
protoc --php_out=src --grpc-web_out=mode=grpcwebtext:src --proto_path=config/proto
```#### Create controller
```php
getMessage();
$response = new PingResponse();
$response->setMessage("pong:" . $message);
return $response;
}
}
```