PHPackages                             zymawy/dgraph - 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. zymawy/dgraph

ActiveLibrary[API Development](/categories/api)

zymawy/dgraph
=============

Fluent API for dgraph

1.0.1(1y ago)3965[1 PRs](https://github.com/zymawy/laravel-dgraph/pulls)MITPHP

Since Jul 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/zymawy/laravel-dgraph)[ Packagist](https://packagist.org/packages/zymawy/dgraph)[ Docs](https://github.com/zymawy/dgraph)[ GitHub Sponsors](https://github.com/zymawy)[ RSS](/packages/zymawy-dgraph/feed)WikiDiscussions main Synced 1mo ago

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

Fluint API for dgraph
=====================

[](#fluint-api-for-dgraph)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3da8c8f4b86383555ec83c2feebbd17f09316d5ea64b47e8668ddaaa3838f517/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a796d6177792f6467726170682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zymawy/dgraph)[![GitHub Tests Action Status](https://camo.githubusercontent.com/400ea213e19e23ea10e89de9ad2eccdb3c01b8232dcc9dbd7a81b4e378c41978/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a796d6177792f6467726170682f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/zymawy/dgraph/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/59903be2e31e0bf75e57109cc7f1afee1e0702734bcd200a8acf77ccd20edf7a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a796d6177792f6467726170682f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/zymawy/dgraph/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/aff51eda4ce39fb69b9e355ec35a3c9be4cae209de4ed3bf6eee83047c35ea1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a796d6177792f6467726170682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zymawy/dgraph)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/3820bd2bcef7da32aff2ae6c55bc9b75d72e65cc9d428d3afc3681b9dec0eff0/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6467726170682e6a70673f743d31)](https://spatie.be/github-ad-click/dgraph)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require zymawy/dgraph
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="dgraph-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="dgraph-config"
```

This is the contents of the published config file:

```
return [
];
```

Optionally, you can publish the views using

```
php artisan vendor:publish --tag="dgraph-views"
```

Usage
-----

[](#usage)

Create a Client
---------------

[](#create-a-client)

```
use Zymawy\Dgraph\DgraphClient;

/** @var DgraphClient $client */
$client = new DgraphClient('http://localhost:8080');
```

### Define and Alter Schema

[](#define-and-alter-schema)

```
use Zymawy\Dgraph\Api\Operation;
use Zymawy\Dgraph\Exceptions\DgraphException;
use Zymawy\Dgraph\Types\StringType;
use Zymawy\Dgraph\Types\IntType;
use Zymawy\Dgraph\DgraphClient;

/** @var DgraphClient $client */
$client = new DgraphClient('http://localhost:8080');

// Define the schema using the Operation class
$operation = new Operation();
$operation
  ->addField("name", new StringType(["index(term)"]))
  ->addField("age", new IntType(["index(int)"]))
  ->addType("person", ["name", "age"]);

try {
    $response = $client->alter($operation);
    if ($response->hasErrors()) {
        throw new DgraphException("Schema alteration error: " . json_encode($response->getErrors()));
    } else {
        echo "Schema successfully altered.";
    }
} catch (DgraphException $e) {
    echo "Error: " . $e->getMessage();
}
```

Add Initial Data
----------------

[](#add-initial-data)

```
use Zymawy\Dgraph\DgraphClient;
use Zymawy\Dgraph\Txn;
use Zymawy\Dgraph\Responses\DgraphResponse;
use Zymawy\Dgraph\Exceptions\DgraphException;
use Zymawy\Dgraph\Types\StringType;
use Zymawy\Dgraph\Types\IntType;
/** @var DgraphClient $client */
$client = new DgraphClient("http://localhost:8080");

use Zymawy\Dgraph\Api\Mutation;
use Zymawy\Dgraph\Exceptions\DgraphException;

/** @var DgraphClient $client */
$client = new DgraphClient("http://localhost:8080");

$mutation = new Mutation();
$mutation->set([
  [
    "uid" => "_:account1",
    "name" => "Hamza",
    "balance" => 1000.0
  ],
  [
    "uid" => "_:account2",
    "name" => "Zymawy",
    "balance" => 500.0
  ]
]);

try {
  $response = $client->mutate($mutation, true); // commitNow set to true
  if ($response->hasErrors()) {
    throw new DgraphException(
      "Mutation error: " . json_encode($response->getErrors())
    );
  } else {
    print_r($response->getData());
  }
} catch (DgraphException $e) {
  echo "Error: " . $e->getMessage();
}
```

Run a Basic Query
-----------------

[](#run-a-basic-query)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [zymawy](https://github.com/zymawy)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

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

679d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fe0842ec0c7189b188c5ca0e77c29ae6af16e93ab96b1eb081af67cb56454fd0?d=identicon)[zymawy](/maintainers/zymawy)

---

Top Contributors

[![zymawy](https://avatars.githubusercontent.com/u/15253683?v=4)](https://github.com/zymawy "zymawy (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelzymawydgraph

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/zymawy-dgraph/health.svg)

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.0k7.8M57](/packages/dedoc-scramble)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[njoguamos/laravel-plausible

A laravel package for interacting with plausible analytics api.

208.8k](/packages/njoguamos-laravel-plausible)

PHPackages © 2026

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