PHPackages                             indiana-university/iukb-api-php - 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. indiana-university/iukb-api-php

ActiveLibrary[API Development](/categories/api)

indiana-university/iukb-api-php
===============================

A set of classes to pull documents from the IU knowledge base into your application

v2.3(4y ago)1641BSD-3-ClausePHPPHP ^7.1 | ^8

Since Jun 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/indiana-university/iukb-api-php)[ Packagist](https://packagist.org/packages/indiana-university/iukb-api-php)[ Docs](https://github.com/indiana-university/iukb-api-php)[ RSS](/packages/indiana-university-iukb-api-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (5)Used By (1)

IUKB API - PHP
==============

[](#iukb-api---php)

A set of classes to pull documents from the IU knowledge base into your PHP application

Requirements
------------

[](#requirements)

- PHP 7 or 8
- Composer
- A knowledge base REST account
    - See [the knowledge base REST api documentation](https://kb.iu.edu/d/rest)for more information

Usage
-----

[](#usage)

To instantiate the KB class, you must simply give it a provider. This is an instance of a class which will pull KB data from somewhere and feed it into the main KB class. There are currently three different providers, however, one of them is simply an intermediary class to provide caching. The two actual data providers are `Filesystem` and `Web`.

### Filesystem

[](#filesystem)

The `Filesystem` class is used for testing purposes, but could be used to provide caching in a different way from the way it is implemented in the caching class. For example, if you need to alter the content of the KB docs before displaying them. You could save the result some where on disk and load it through the `Filesystem` provider.

```
require(__dir__ . '/vendor/autoload.php');

use \Edu\Iu\Uits\KnowledgeBase\Provider\Filesystem\Filesystem;

$provider = new Filesystem(__dir__ . '/kbCache/');
```

### Web

[](#web)

The `Web` class is used to load data from the Knowledge Base REST API. It requires credentials to authenticate to the REST API.

```
require(__dir__ . '/vendor/autoload.php');

use \Edu\Iu\Uits\KnowledgeBase\Provider\Web\Web;

$provider = new Web('https://rest.kb.iu.edu', 'username', 'password');
```

### Instantiating the KB class

[](#instantiating-the-kb-class)

```
require(__dir__ . '/vendor/autoload.php');

use \Edu\Iu\Uits\KnowledgeBase\KnowledgeBase;
use \Edu\Iu\Uits\KnowledgeBase\Provider\Web\Web;

$provider = new Web('https://rest.kb.iu.edu', 'username', 'password');

$kb = new KnowledgeBase($provider);
```

### Caching

[](#caching)

In previous versions caching was built into the main class, but the resulting implementation was quite messy. It also forced users to use a cache even if they did not want to. Caching is now provided by a separate intermediate provider.

The cache class requires a provider, a cache object, and a TTL. The default time for the TTL is 3600 seconds.

Also note that the Caching provider will also cache search results. It will always refresh the search result cache after the TTL though as there is no way to check if the search results have changed.

```
require(__dir__ . '/vendor/autoload.php');

use \Doctrine\Common\Cache\ApcuCache;
use \Edu\Iu\Uits\KnowledgeBase\KnowledgeBase;
use \Edu\Iu\Uits\KnowledgeBase\Provider\{
    Caching\Caching,
    Web\Web,
};

$kb_provider = new Web('https://rest.kb.iu.edu', 'username', 'password');
$cache = new ApucCache();
$provider = new Caching($kb_provider, $cache);

$kb = new KnowledgeBase($provider);
```

### Fetching a document

[](#fetching-a-document)

```
$doc = $kb->getDocument('rest');
echo $doc->getContent();
```

### Searching the KB

[](#searching-the-kb)

```
$search = $kb->getSearch('outlook');
foreach ($search->getResults() as $result) {
    echo "[{$result->getDocid()}] {$result->getTitle()}" . PHP_EOL;
}
```

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

[](#contributing)

Contributions are welcome in the form of a github pull request. Note, for consistency sake, please run `composer check` and `composer run-tests` on any code you wish to contribute to this project and fix and resolve any issues found.

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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 ~281 days

Total

4

Last Release

1664d ago

PHP version history (2 changes)v2.0PHP ^7.1

v2.3PHP ^7.1 | ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cd3e0962f4c279ae14bab14c1a450e17f8dec2bfe0a7751f1362894eb48dd7f?d=identicon)[indiana-university](/maintainers/indiana-university)

---

Top Contributors

[![jhoerr](https://avatars.githubusercontent.com/u/1151206?v=4)](https://github.com/jhoerr "jhoerr (1 commits)")

---

Tags

basekbknowledgeIUuits

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/indiana-university-iukb-api-php/health.svg)

```
[![Health](https://phpackages.com/badges/indiana-university-iukb-api-php/health.svg)](https://phpackages.com/packages/indiana-university-iukb-api-php)
```

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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