PHPackages                             fadhila36/grpcavel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. fadhila36/grpcavel

ActiveLibrary[API Development](/categories/api)

fadhila36/grpcavel
==================

A Laravel-native gRPC framework with code-first protobuf generation and RoadRunner runtime.

v1.0.0(1mo ago)00MITPHPPHP ^8.2CI passing

Since May 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Fadhila36/grpcavel)[ Packagist](https://packagist.org/packages/fadhila36/grpcavel)[ RSS](/packages/fadhila36-grpcavel/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (3)Used By (0)

Grpcavel
========

[](#grpcavel)

 [![Grpcavel Logo](art/logo.png)](art/logo.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/430028646e3d76bcd785965ff94f4248f74d4f2d617e53b1453000c1dd5a7a8d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f66616468696c6133362f677270636176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/fadhila36/grpcavel)[![License](https://camo.githubusercontent.com/0665faba11d2e6c2f7b8829bf52cca3cf4eb08f8810cc36ae9626ad6f43668ad/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f66616468696c6133362f677270636176656c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/fadhila36/grpcavel/blob/main/LICENSE.md)[![Tests](https://github.com/fadhila36/grpcavel/actions/workflows/tests.yml/badge.svg)](https://github.com/fadhila36/grpcavel/actions/workflows/tests.yml)

Grpcavel is a gRPC framework for Laravel that focuses on developer experience. It uses a code-first approach to generate and compile protobuf files, meaning you don't have to write `.proto` definitions manually.

Why Grpcavel?
-------------

[](#why-grpcavel)

Building gRPC services in PHP is traditionally painful. Grpcavel makes it feel like building a standard Laravel API:

- **Code-First**: Your PHP classes are the source of truth. Protos are generated automatically.
- **RoadRunner Runtime**: Uses a persistent worker model for extreme performance.
- **Laravel Native**: Supports Laravel validation, middleware, and Eloquent out of the box.

### Why Grpcavel over Node.js or Golang?

[](#why-grpcavel-over-nodejs-or-golang)

For many engineering teams, Laravel serves as the core application stack. Grpcavel was designed to empower PHP developers with the raw performance and efficiency of gRPC, eliminating the need to adopt new languages or fragment the technology stack solely for inter-service communication.

By leveraging RoadRunner's persistent worker architecture, Grpcavel delivers performance that challenges traditional PHP limitations. The goal is not to replace Go or Node.js, but to provide a seamless, high-performance gRPC implementation tailored specifically for the Laravel ecosystem.

### Key Use Cases

[](#key-use-cases)

- **Enterprise Microservices**: Orchestrate communication between distributed Laravel applications.
- **High-Throughput Internal APIs**: Build low-latency internal services.
- **Optimized Backend Communication**: Achieve faster serialization and transmission than traditional REST/JSON.
- **Polyglot Integration**: Connect Laravel services with other languages using strictly typed, auto-generated protobuf schemas.
- **Real-time Systems Support**: Provide a robust foundation for mobile backends and high-frequency systems.

Benchmarks
----------

[](#benchmarks)

Grpcavel leverages RoadRunner's persistent worker model, yielding performance that significantly outpaces traditional PHP-FPM setups.

Here is a real benchmark conducted on a local development machine (Laptop) simulating a real-world scenario with **Database Interaction** (reading from SQLite):

SetupRequests per Second (RPS)Total RequestsConcurrencySuccess Rate**Grpcavel (RoadRunner)****~140 RPS**1,00050100%### Benchmark Details

[](#benchmark-details)

- **Tool**: `ghz` (gRPC load testing tool)
- **Scenario**: Fetching a user by ID from database via Eloquent.
- **Hardware**: Local development machine (Windows).
- **Workers**: 4 RoadRunner workers.

*Note: This is a real-world benchmark involving database I/O. For simple "echo" or non-DB services, performance can reach thousands of requests per second.*

Compatibility
-------------

[](#compatibility)

Grpcavel is tested against multiple Laravel and PHP versions to ensure stability:

Laravel VersionPHP Version**10.x**8.2, 8.3**11.x**8.2, 8.3, 8.4**12.x**8.2, 8.3, 8.4**13.x**8.3, 8.4Documentation
-------------

[](#documentation)

Full documentation is available at [github.com/Fadhila36/grpcavel-docs](https://github.com/Fadhila36/grpcavel-docs).

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require fadhila36/grpcavel
```

After installing, run the install command to prepare the environment:

```
php artisan grpc:install
```

Usage
-----

[](#usage)

### 1. Create a Service

[](#1-create-a-service)

Generate a new service class using Artisan:

```
php artisan grpc:make-service UserService
```

### 2. Define Methods

[](#2-define-methods)

Annotate your service methods with `#[GrpcMethod]`. Each method must accept one request DTO and return one response DTO.

```
namespace App\Grpc\Services;

use Grpcavel\Attributes\GrpcService;
use Grpcavel\Attributes\GrpcMethod;
use App\Grpc\Requests\GetUserRequest;
use App\Grpc\Responses\UserResponse;

#[GrpcService]
class UserService
{
    #[GrpcMethod]
    public function getUser(GetUserRequest $request): UserResponse
    {
        $user = \App\Models\User::findOrFail($request->id);

        return UserResponse::fromModel($user);
    }
}
```

### 3. Validation

[](#3-validation)

Define rules in your request DTO by extending `GrpcRequest`:

```
class GetUserRequest extends GrpcRequest
{
    public function __construct(public readonly int $id) {}

    public function rules(): array
    {
        return ['id' => 'required|integer|exists:users,id'];
    }
}
```

### 4. Synchronization

[](#4-synchronization)

Sync your PHP definitions with `.proto` files and compile the stubs:

```
php artisan grpc:sync
```

### 5. Start the Server

[](#5-start-the-server)

Start the RoadRunner gRPC server:

```
php artisan grpc:start
```

Middleware
----------

[](#middleware)

You can apply middleware to services or individual methods using attributes:

```
#[GrpcService]
#[Middleware(Authenticate::class)]
class SecureService {
    #[GrpcMethod]
    #[Middleware(LogRequest::class)]
    public function handle(...) {}
}
```

Enterprise Features
-------------------

[](#enterprise-features)

### Rate Limiting

[](#rate-limiting)

Protect your services from abuse using the built-in `RateLimitMiddleware`. Configure limits in `config/grpc.php` and apply it to your services:

```
#[GrpcService]
#[Middleware(\Grpcavel\Middleware\RateLimitMiddleware::class)]
class PublicService { ... }
```

### Docker Support

[](#docker-support)

Deploy with confidence using the included production-optimized `Dockerfile`. It handles PHP 8.3, RoadRunner binaries, and necessary extensions out of the box.

### Client Scaffolding

[](#client-scaffolding)

Generate client-side wrappers to facilitate communication between microservices:

```
php artisan grpc:make-client UserServiceClient
```

Testing
-------

[](#testing)

Grpcavel provides a `GrpcClient` to test your services in-process:

```
$response = GrpcClient::call(UserService::class, 'getUser', new GetUserRequest(id: 1));

expect($response)->toBeInstanceOf(UserResponse::class);
```

Production Optimization
-----------------------

[](#production-optimization)

### Service Discovery Cache

[](#service-discovery-cache)

In production, you can cache your service definitions to avoid the overhead of scanning directories and using reflection:

```
php artisan grpc:cache
```

To clear the cache:

```
php artisan grpc:clear
```

### Runtime Stability

[](#runtime-stability)

Grpcavel is hardened for long-lived processes:

- **Memory Management**: Automatically flushes query logs and triggers garbage collection after each request.
- **Database Resilience**: Detects and recovers lost database connections between requests.

Commands Reference
------------------

[](#commands-reference)

CommandDescription`grpc:install`Bootstrap directories and config.`grpc:sync`Generate and compile proto files.`grpc:compile`Manually compile proto files.`grpc:cache`Create service discovery cache.`grpc:clear`Remove service discovery cache.`grpc:start`Start the gRPC server.`grpc:make-service`Create a new service.`grpc:make-client`Create a client wrapper.`grpc:make-request`Create a request DTO.`grpc:make-response`Create a response DTO.Support the Project
-------------------

[](#support-the-project)

If you find Grpcavel helpful, please consider giving it a star ⭐ on GitHub! It helps more developers discover the project and motivates us to keep improving it.

[![Star History Chart](https://camo.githubusercontent.com/2780ceed227902d0c5a81a7a34280d2c073731b5e6b4c2ba2d9a244516f85a0b/68747470733a2f2f6170692e737461722d686973746f72792e636f6d2f7376673f7265706f733d66616468696c6133362f677270636176656c26747970653d44617465)](https://star-history.com/#fadhila36/grpcavel&Date)

Open Source &amp; Contributing
------------------------------

[](#open-source--contributing)

Grpcavel is an open-source project, and we welcome contributions from the community! Whether it's reporting a bug, proposing a new feature, or submitting a Pull Request, your help is highly appreciated.

If you're interested in contributing, please feel free to fork the repository and submit a PR. For major changes, please open an issue first to discuss what you would like to change.

Credits
-------

[](#credits)

- [Muhammad Fadhila Abiyyu Faris](https://github.com/Fadhila36)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

31d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/37483304?v=4)[Muhammad Fadhila Abiyyu Faris](/maintainers/Fadhila36)[@Fadhila36](https://github.com/Fadhila36)

---

Tags

code-firstframeworkgrpclaravelmicroservicephpprotobufroadrunner

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fadhila36-grpcavel/health.svg)

```
[![Health](https://phpackages.com/badges/fadhila36-grpcavel/health.svg)](https://phpackages.com/packages/fadhila36-grpcavel)
```

###  Alternatives

[google/gax

Google API Core for PHP

268111.6M515](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

175112.8M64](/packages/google-common-protos)[googleads/google-ads-php

Google Ads API client for PHP

3478.1M11](/packages/googleads-google-ads-php)[google/grpc-gcp

gRPC GCP library for channel management

184106.3M4](/packages/google-grpc-gcp)[temporal/sdk

Temporal SDK

4082.7M22](/packages/temporal-sdk)[clarifai/clarifai-php-grpc

Clarifai PHP gRPC client

1229.3k](/packages/clarifai-clarifai-php-grpc)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
