PHPackages                             jeffreyvanrossum/contextr - 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. jeffreyvanrossum/contextr

ActiveLibrary

jeffreyvanrossum/contextr
=========================

Determine context with AI.

0.1.2(4mo ago)0481MITPHPPHP ^8.0|^8.1|^8.2CI passing

Since Mar 12Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/jeffreyvr/contextr)[ Packagist](https://packagist.org/packages/jeffreyvanrossum/contextr)[ RSS](/packages/jeffreyvanrossum-contextr/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (8)Versions (4)Used By (1)

   ![contextr logo](./art/logo-dark.svg) ### contextr

[](#contextr)

[![Total Downloads](https://camo.githubusercontent.com/16aa0a433ff1a5e5985432f4ff13d600be509a489421255c88cb11a08b71b904/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a65666672657976616e726f7373756d2f636f6e7465787472)](https://packagist.org/packages/jeffreyvanrossum/contextr)[![Latest Stable Version](https://camo.githubusercontent.com/3214e5587489f978ffcdb260ac705b33fd00aa9b648e781a2fa2b87be6ff10dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a65666672657976616e726f7373756d2f636f6e7465787472)](https://packagist.org/packages/jeffreyvanrossum/contextr)[![License](https://camo.githubusercontent.com/4f4395e88a76a315831e76e222e2f7ba93f68077e2e9e60aacb348653f7eedcd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a65666672657976616e726f7373756d2f636f6e7465787472)](https://packagist.org/packages/jeffreyvanrossum/contextr)

Use AI as your intelligent assistant to analyze text for spam, sentiment, and moderation, delivering precise insights with confidence scores and detailed reasoning.

Usage
-----

[](#usage)

### Installation

[](#installation)

```
composer require jeffreyvanrossum/contextr
```

### Setup

[](#setup)

First, you need to setup your instance of contextr.

You can use [OpenAI](http://platform.openai.com/) or [Grok](https://x.ai/api) as AI providers.

```
$contextr = new Contextr\Contextr(provider: new Contextr\Providers\OpenAi(apiKey: 'API_KEY'));

// Or for Grok:

$contextr = new Contextr\Contextr(provider: new Contextr\Providers\Grok(apiKey: 'API_KEY'));
```

### Examples

[](#examples)

##### Spam

[](#spam)

```
$check = $contextr->spam()
    ->text('Buy cheap viagra now!!! Click here: shady.link')
    ->context([
        'topic' => 'Health Forum Discussion',
        'user_history' => 'First time poster'
    ])
    ->withReasoning()
    ->analyze();

$check->data();         // full result array
$check->spam();         // true (boolean)
$check->confidence();   // 0.95 (float)
$check->reasoning();    // "Contains promotional content and suspicious link"
```

##### Sentiment

[](#sentiment)

Determine if the sentiment is `positive`, `negative` or `neutral`.

```
$check = $contextr->sentiment()
    ->text('This blu ray was great, too bad it did not include Project A.')
    ->context([
        'product' => 'Jackie Chan Collection Vol 1983',
        'category' => 'Blu ray'
    ])
    ->withReasoning()
    ->analyze();

$check->data();         // full result array
$check->sentiment();    // neutral (string)
$check->confidence();   // 0.75 (float)
$check->reasoning();    // "Expresses enjoyment of the blu ray but also disappointment about the absence of a specific content." (string)
```

##### Moderation

[](#moderation)

Determine if user comments violate moderation rules.

```
$check = $contextr->moderation()
    ->text('These morons don’t even know how to kick a ball properly!')
    ->rules(['hate speech', 'profanity', 'civility'])
    ->context([
        'platform' => 'sports news website',
        'topic' => 'Premier League match review'
    ])
    ->withReasoning()
    ->withViolations()
    ->analyze();

$check->data();         // full result array
$check->violates();     // true (boolean)
$check->confidence();   // 0.75 (float)
$check->violations();   // ['profanity', 'civility'] (array)
$check->reasoning();    // "Contains insulting language and lacks respectful tone"
```

##### AI

[](#ai)

Determine the likelyhood that a text is AI-generated.

```
$check = $contextr->ai()
    ->text('The strategic intricacies of modern football necessitate a comprehensive understanding of player positioning, tactical adaptability, and cohesive team synergy to achieve superior performance outcomes.')
    ->context([
        'platform' => 'football fan forum',
        'topic' => 'Post-match discussion: Manchester United vs. Liverpool',
        'user_history' => 'New account, posted 5 similar analyses in 24 hours'
    ])
    ->withReasoning()
    >analyze();

$check->data();         // full result array
$check->ai();           // true (boolean)
$check->confidence();   // 0.92 (float)
$check->reasoning();    // "Overly polished language and generic analysis typical of AI-generated text, especially given the user's pattern of similar posts."
```

contextr as a service? 👀
------------------------

[](#contextr-as-a-service-)

Would you like this API, but as a hosted service, with a nice interface to define custom base templates?

*[Join the waitlist](https://contextr.dev)*

Contributors
------------

[](#contributors)

- [Jeffrey van Rossum](https://github.com/jeffreyvr)
- [All contributors](https://github.com/contextr-dev/contextr/graphs/contributors)

License
-------

[](#license)

MIT. Please see the [License File](/LICENSE) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance74

Regular maintenance activity

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity42

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

Total

3

Last Release

145d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/66ca71465f93459010e10f39821b541f1c00c61233c48bcda0cea8a8d6fb6988?d=identicon)[jeffreyvr](/maintainers/jeffreyvr)

---

Top Contributors

[![jeffreyvr](https://avatars.githubusercontent.com/u/9550079?v=4)](https://github.com/jeffreyvr "jeffreyvr (21 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jeffreyvanrossum-contextr/health.svg)

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

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)

PHPackages © 2026

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