PHPackages                             freearhey/knowledge-graph - 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. freearhey/knowledge-graph

ActiveLibrary[API Development](/categories/api)

freearhey/knowledge-graph
=========================

A simple PHP client for working with Google Knowledge Graph API

2.4.0(5y ago)540.5kMITPHPCI failing

Since Oct 19Pushed 5y ago2 watchersCompare

[ Source](https://github.com/freearhey/knowledge-graph)[ Packagist](https://packagist.org/packages/freearhey/knowledge-graph)[ Docs](https://github.com/freearhey/knowledge-graph)[ RSS](/packages/freearhey-knowledge-graph/feed)WikiDiscussions master Synced 3d ago

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

Knowledge Graph [![Build Status](https://camo.githubusercontent.com/e37b70ccb80cf74fc5d3e94fc010c69991c1ee79faaeec1c764cd9a684e1a6d1/68747470733a2f2f7472617669732d63692e6f72672f6672656561726865792f6b6e6f776c656467652d67726170682e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/freearhey/knowledge-graph)
==========================================================================================================================================================================================================================================================================================================================

[](#knowledge-graph-)

A simple PHP client for working with [Google Knowledge Graph API](https://developers.google.com/knowledge-graph/).

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

[](#installation)

```
composer require freearhey/knowledge-graph
```

Usage
-----

[](#usage)

```
require_once('vendor/autoload.php');

use KnowledgeGraph\Client;
use KnowledgeGraph\KnowledgeGraph;

$client = new Client();

$client->setKey('YOUR_API_KEY'); // More about API Key here: https://developers.google.com/knowledge-graph/how-tos/authorizing

$graph = new KnowledgeGraph($client);
```

### Available Methods

[](#available-methods)

#### `search()`

[](#search)

The `search` method give you a way to search in Knowledge Graph by entity name.

```
$results = $graph->search($query, $type, $lang, $limit);
```

Arguments:

- `$query`: term to search (required)
- `$type`: specify the type of results (e.g. "Book") (List of available types: )
- `$lang`: specify the results language
- `$limit`: set a custom limit (default: 20)

Example:

```
$results = $graph->search('taylor swift');

/*
  Collection {
    #items: array:20 [
      0 => SearchResult {
        id: "/m/0dl567"
        score: 1466.352905
        name: "Taylor Swift"
        type: array:2 [
          0 => "Thing"
          1 => "Person"
        ]
        description: "American singer"
        image: array:2 [
          "contentUrl" => "http://t0.gstatic.com/images?q=tbn:ANd9GcST848UJ0u31E6aoQfb2nnKZFyad7rwNF0ZLOCACGpu4jnboEzV"
          "url" => "https://en.wikipedia.org/wiki/Begin_Again_(Taylor_Swift_song)"
        ]
        detailedDescription: array:3 [
          "articleBody" => "Taylor Alison Swift is an American singer-songwriter. As one of the world's leading contemporary recording artists, she is known for narrative songs about her p ▶"
          "url" => "https://en.wikipedia.org/wiki/Taylor_Swift"
          "license" => "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
        ]
        url: "http://taylorswift.com/"
      }
      ...
    ]
  }
 */
```

The `search` method always returns `Illuminate\Support\Collection` class with results. This means you can use all the [methods available](https://laravel.com/docs/5.6/collections#available-methods) in Laravel's Collections.

#### `find()`

[](#find)

The `find` method give you a way to search by entity ID.

```
$results = $graph->find($id, $lang);
```

Arguments:

- `$id`: ID to search (e.g. "/m/0dl567")
- `$lang`: specify the results language

Example:

```
$results = $graph->find('/m/02j81');

/*
  SearchResult {
    id: "/m/02j81"
    score: 26.98455
    name: "Eiffel Tower"
    type: array:5 [
      0 => "Thing"
      1 => "CivicStructure"
      2 => "Place"
      3 => "TouristAttraction"
      4 => "Organization"
    ]
    description: "Tower in Paris, France"
    image: array:2 [
      "contentUrl" => "http://t1.gstatic.com/images?q=tbn:ANd9GcSao5YmaJqJVcSi60m9ypkaIC6bjKVJdoocuGBzgyTIu4MaMJ-t"
      "url" => "https://commons.wikimedia.org/wiki/File:Eiffel_tower.svg"
    ]
    detailedDescription: array:3 [
      "articleBody" => "The Eiffel Tower is a wrought-iron lattice tower on the Champ de Mars in Paris, France. It is named after the engineer Gustave Eiffel, whose company designed an ▶"
      "url" => "https://en.wikipedia.org/wiki/Eiffel_Tower"
      "license" => "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
    ]
    url: "http://www.eiffel-tower.com/"
  }
 */
```

### Testing

[](#testing)

```
API_KEY=YOUR_API_KEY vendor/bin/phpunit
```

### Contribution

[](#contribution)

If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/freearhey/knowledge-graph/issues) or a [pull request](https://github.com/freearhey/knowledge-graph/pulls).

### License

[](#license)

Knowledge Graph is licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~195 days

Recently: every ~116 days

Total

7

Last Release

1956d ago

Major Versions

1.0.0 → 2.0.12019-03-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d0a0ca5e503bd0e74ab4ccdecb0d205ac8fc1bf543574e9bc337f659ac5abf5?d=identicon)[Arhey](/maintainers/Arhey)

---

Top Contributors

[![freearhey](https://avatars.githubusercontent.com/u/7253922?v=4)](https://github.com/freearhey "freearhey (52 commits)")

---

Tags

phpapiclientgooglegraphknowledge

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/freearhey-knowledge-graph/health.svg)

```
[![Health](https://phpackages.com/badges/freearhey-knowledge-graph/health.svg)](https://phpackages.com/packages/freearhey-knowledge-graph)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[kunalvarma05/dropbox-php-sdk

Dropbox PHP API V2 SDK (Unofficial)

3633.0M18](/packages/kunalvarma05-dropbox-php-sdk)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[gemini-api-php/client

API client for Google's Gemini API

216221.4k5](/packages/gemini-api-php-client)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[gemini-api-php/laravel

Gemini API client for Laravel

8915.7k](/packages/gemini-api-php-laravel)

PHPackages © 2026

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