PHPackages                             darrynten/watson-personality-insights-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. darrynten/watson-personality-insights-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

darrynten/watson-personality-insights-php
=========================================

PHP Watson Personality Insights Client with Extras

v1.0.1(9y ago)141.4k3[1 issues](https://github.com/darrynten/watson-personality-insights-php/issues)PHPPHP ^5.5.9 || ^7.0

Since Feb 18Pushed 9y ago3 watchersCompare

[ Source](https://github.com/darrynten/watson-personality-insights-php)[ Packagist](https://packagist.org/packages/darrynten/watson-personality-insights-php)[ RSS](/packages/darrynten-watson-personality-insights-php/feed)WikiDiscussions dev Synced 4w ago

READMEChangelog (2)Dependencies (5)Versions (4)Used By (0)

watson-personality-insights-php
-------------------------------

[](#watson-personality-insights-php)

[![Travis Build Status](https://camo.githubusercontent.com/de52cee5a918ede00bc7e12ddb61fae6ddcdafd5b64ddd246a16cd4f946343e2/68747470733a2f2f7472617669732d63692e6f72672f64617272796e74656e2f776174736f6e2d706572736f6e616c6974792d696e7369676874732d7068702e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/de52cee5a918ede00bc7e12ddb61fae6ddcdafd5b64ddd246a16cd4f946343e2/68747470733a2f2f7472617669732d63692e6f72672f64617272796e74656e2f776174736f6e2d706572736f6e616c6974792d696e7369676874732d7068702e7376673f6272616e63683d6d6173746572)[![StyleCI Status](https://camo.githubusercontent.com/c4eedd889a201c43b2387529eaca40eacd937bcae34f89ead190a1f9f68ff30f/68747470733a2f2f7374796c6563692e696f2f7265706f732f38313638373331302f736869656c643f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/c4eedd889a201c43b2387529eaca40eacd937bcae34f89ead190a1f9f68ff30f/68747470733a2f2f7374796c6563692e696f2f7265706f732f38313638373331302f736869656c643f6272616e63683d6d6173746572)[![codecov](https://camo.githubusercontent.com/f35eb757b9473a0b2f31226831bb4e7c4348b853b46a8aa633cd6037d95853b7/68747470733a2f2f636f6465636f762e696f2f67682f64617272796e74656e2f776174736f6e2d706572736f6e616c6974792d696e7369676874732d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/darrynten/watson-personality-insights-php)[![Packagist Version](https://camo.githubusercontent.com/5619105483e65b626a05763f07657e273aee4c3f17065e2383432607c805339e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64617272796e74656e2f776174736f6e2d706572736f6e616c6974792d696e7369676874732d7068702e737667)](https://camo.githubusercontent.com/5619105483e65b626a05763f07657e273aee4c3f17065e2383432607c805339e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64617272796e74656e2f776174736f6e2d706572736f6e616c6974792d696e7369676874732d7068702e737667)[![MIT License](https://camo.githubusercontent.com/a6782471d07ddd844836e3d3f3ec04a86ce29cb66bbfaf1e77133a442b254c94/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64617272796e74656e2f776174736f6e2d706572736f6e616c6974792d696e7369676874732d7068702e737667)](https://camo.githubusercontent.com/a6782471d07ddd844836e3d3f3ec04a86ce29cb66bbfaf1e77133a442b254c94/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f64617272796e74656e2f776174736f6e2d706572736f6e616c6974792d696e7369676874732d7068702e737667)

A framework agnostic fully unit tested client for IBM Watson Personality insights API.

For PHP 7.0+

### Install

[](#install)

```
composer require darrynten/watson-personality-insights-php
```

### Usage

[](#usage)

```
// Required config
$config = [
    'username' => $username,
    'password' => $password
];

// Get an instance
$instance = new PersonalityInsights($config);

// Add some text
$text = file_get_contents('sample.txt');
$instance->addText($text);

// Get the insights
$insights = $instance->getInsights();
```

Some things you can set

```
// Set standard options
$instance->config->setConsumptionPreferences(true);
$instance->config->setRawScores(true);
$instance->config->setVersion('2017-01-01');
$instance->config->setContentTypeHeader('application/json');
$instance->config->setContentLanguageHeader('en');
$instance->config->setAcceptHeader('application/json');
$instance->config->setAcceptLanguageHeader('en');
$instance->config->setCsvHeaders(false);
// https://watson-api-explorer.mybluemix.net/apis/personality-insights-v3#!/personality45insights/profile

// Set caching of requests
$instance->config->setCaching(false);

// Opt in to Watson tracking (off by default)
$instance->config->setOptOut(false);

// All config options
$config = [
    'username' => $username,
    'password' => $password,
    'version' => $version,
    'raw_scores' => $boolean,
    'consumption_preferences' => $boolean,
    'cache' => $boolean,
];
```

You can also add a `ContentItem` directly

```
/**
 * All possible content item config options. Only the `text` one is
 * required.
 *
 * https://watson-api-explorer.mybluemix.net/apis/personality-insights-v3#!/personality45insights/profile
 *
 * Defaults
 *
 * id - An md5 of the text
 * created - 0
 * updated - 0
 * contenttype - 'text/plain'
 * language - en
 * parentid - null
 * reply - false
 * forward - false
 */
$contentConfig = [
    'text' => $text,          // The only required value
    'id' => $string,          // Is the md5 of the text if not set
    'created' => $timestamp,  // Is 0 if not set
    'updated' => $timestamp,  // Is 0 if not set
    'contenttype' => $string, // `text/plain` or `text/html`
    'language' => $string,    // `en` or similar
    'parentid' => $string,    // The ID of a parent item. Null if not set
    'reply' => $boolean,      // Indicates if it is a reply to another
    'forward' => $boolean,    // Indicates if it is a forwarded text
];

$contentItem = new ContentItem($contentConfig);
$contentItem->getContentItemJson();

$instance->addNewContentItem($contentItem);
```

Notes
-----

[](#notes)

### Privacy

[](#privacy)

IBM have a mode that keeps a copy of your data on their side for the apparent training of Watson. This is normally opt-out.

As this isn't explicitly made clear, we have decided to **disable by default** so if you do with to help Watson learn then you can do so by opting-in as outlined in the examples above.

By default this package will not allow any tracking of any kind.

### "Version"

[](#version)

This is the source of some confusion. This is a date in the format of 'YYYY-MM-DD' and Watson will use whichever version was around at that time.

Full quote

> The requested version of the response format as a date in the form YYYY-MM-DD; for example, specify 2016-10-20 for October 20, 2016. The date that you specify does not need to match a version of the service exactly; the service replies with the response format whose version is no later than the date you provide. If you specify a date that is earlier than the initial release of version 3, the service returns the response format for that first version. If you specify a date that is in the future or otherwise later than the most recent version, the service returns the response format for the latest version.

### Credentials

[](#credentials)

You can download your credentials in a `json` file, or get them from the developer console.

[Details on IBM](https://www.ibm.com/watson/developercloud/doc/getting_started/gs-credentials.shtml)

### Unit tests

[](#unit-tests)

Test coverage is 100%, but you can also include a live API test to see if everything is working on that end. You shouldn't have to though, but it can be useful.

To do live test export

```
export DO_LIVE_API_TESTS=true
```

You must also include your real `credentials.json` in the root of the project (it is already in the `gitignore`).

Which will then do the live test.

### Not yet supported

[](#not-yet-supported)

- Delete from ContentItems collection
- Modify within ContentItems collection
- Full error and exception handling
- Manipulation of the results
- Minimum text length configuration
- CSV

Contributing and Testing
------------------------

[](#contributing-and-testing)

There is currently 100% test coverage in the project, please ensure that when contributing you update the tests. For more info see CONTRIBUTING.md

Acknowledgements
----------------

[](#acknowledgements)

- [Dmitry Semenov](https://github.com/mxnr), as always.
- Add yourself here!

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 97.1% 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 ~0 days

Total

2

Last Release

3419d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3657251?v=4)[Darryn Ten](/maintainers/darrynten)[@darrynten](https://github.com/darrynten)

---

Top Contributors

[![darrynten](https://avatars.githubusercontent.com/u/3657251?v=4)](https://github.com/darrynten "darrynten (33 commits)")[![mxnr](https://avatars.githubusercontent.com/u/1383089?v=4)](https://github.com/mxnr "mxnr (1 commits)")

---

Tags

aiartificial-intelligenceclientcoverageframework-agnosticibmibm-watson-servicesmachine-learningphpphp-libraryphp7unit-testedwatson

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/darrynten-watson-personality-insights-php/health.svg)

```
[![Health](https://phpackages.com/badges/darrynten-watson-personality-insights-php/health.svg)](https://phpackages.com/packages/darrynten-watson-personality-insights-php)
```

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k34](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751284.3k37](/packages/civicrm-civicrm-core)[roundcube/roundcubemail

The Roundcube Webmail suite

7.0k1.4k3](/packages/roundcube-roundcubemail)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[nfse-nacional/nfse-php

This is my package nfse

1533.1k](/packages/nfse-nacional-nfse-php)

PHPackages © 2026

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