PHPackages                             davmixcool/php-sentiment-analyzer - 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. davmixcool/php-sentiment-analyzer

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

davmixcool/php-sentiment-analyzer
=================================

PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).

1.2.2(5y ago)136173.7k↓22.7%36[1 PRs](https://github.com/davmixcool/php-sentiment-analyzer/pulls)1MITPHPPHP &gt;=5.5.9

Since Aug 29Pushed 3y ago4 watchersCompare

[ Source](https://github.com/davmixcool/php-sentiment-analyzer)[ Packagist](https://packagist.org/packages/davmixcool/php-sentiment-analyzer)[ Docs](https://github.com/davmixcool/php-sentiment-analyzer)[ RSS](/packages/davmixcool-php-sentiment-analyzer/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (4)DependenciesVersions (6)Used By (1)

PHP Sentiment Analyzer
======================

[](#php-sentiment-analyzer)

PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).

[![GitHub license](https://camo.githubusercontent.com/3ed09c031718e7f5caa27986187b60ae400b134b2273bed5931f499d943441ca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6461766d6978636f6f6c2f7068702d73656e74696d656e742d616e616c797a65722e737667)](https://github.com/davmixcool/php-sentiment-analyzer/blob/master/LICENSE) [![GitHub issues](https://camo.githubusercontent.com/cf3112b70eafaf5f01084db2ab8497cddd9bc6a99639f0ed0f4a5f0ff1760786/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6461766d6978636f6f6c2f7068702d73656e74696d656e742d616e616c797a65722e737667)](https://github.com/davmixcool/php-sentiment-analyzer/issues) [![Stable](https://camo.githubusercontent.com/957ef64e5d248b1f6f8715591700e0f091bedb77664fcb8fc433df09e8822dac/68747470733a2f2f706f7365722e707567782e6f72672f6461766d6978636f6f6c2f7068702d73656e74696d656e742d616e616c797a65722f762f737461626c652e737667)](https://poser.pugx.org/davmixcool/php-sentiment-analyzer/v/stable.svg) [![Download](https://camo.githubusercontent.com/c245d5a40ea45c1384dd09f29df4c2aab15e522ec0632d10a908c7d6d778c559/68747470733a2f2f706f7365722e707567782e6f72672f6461766d6978636f6f6c2f7068702d73656e74696d656e742d616e616c797a65722f642f746f74616c2e737667)](https://poser.pugx.org/davmixcool/php-sentiment-analyzer/d/total.svg) [![Twitter](https://camo.githubusercontent.com/ea83407cf6cfca2a115951298e234e151ae470fc8a39c5e95d26a963b0572980/68747470733a2f2f696d672e736869656c64732e696f2f747769747465722f75726c2f68747470732f6769746875622e636f6d2f6461766d6978636f6f6c2f7068702d73656e74696d656e742d616e616c797a65722e7376673f7374796c653d736f6369616c)](https://twitter.com/intent/tweet?text=Wow:&url=https%3A%2F%2Fgithub.com%2Fdavmixcool%2Fphp-sentiment-analyzer)

Features
--------

[](#features)

- Text
- Emoticon
- Emoji

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

[](#requirements)

- PHP 5.5 and above

Steps:
------

[](#steps)

- [Install](./#install)
- [Usage](./#usage)
- [Stargazers](./#stargazers)
- [Forkers](./#forkers)
- [License](./#license)
- [Reference](./#reference)

### Install

[](#install)

**Composer**

Run the following to include this via Composer

```
composer require davmixcool/php-sentiment-analyzer

```

### Simple Usage

[](#simple-usage)

```
Use Sentiment\Analyzer;
$analyzer = new Analyzer();

$output_text = $analyzer->getSentiment("David is smart, handsome, and funny.");

$output_emoji = $analyzer->getSentiment("😁");

$output_text_with_emoji = $analyzer->getSentiment("Aproko doctor made me 🤣.");

print_r($output_text);
print_r($output_emoji);
print_r($output_text_with_emoji);
```

### Simple Outputs

[](#simple-outputs)

```
David is smart, handsome, and funny. ---------------- ['neg'=> 0.0, 'neu'=> 0.337, 'pos'=> 0.663, 'compound'=> 0.7096]

😁 ------------------- ['neg' => 0, 'neu' => 0.5, 'pos' => 0.5, 'compound' => 0.4588]

Aproko doctor made me 🤣 ------------- ['neg' => 0, 'neu' => 0.714, 'pos' =>  0.286, 'compound' => 0.4939]

```

### Advanced Usage

[](#advanced-usage)

You can now dynamically update the VADER (Valence) lexicon on the fly for words that are not in the dictionary. See the Example below:

```
Use Sentiment\Analyzer;

$sentiment = new Sentiment\Analyzer();

$strings = [
    'Weather today is rubbish',
    'This cake looks amazing',
    'His skills are mediocre',
    'He is very talented',
    'She is seemingly very agressive',
    'Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.',
    'To be or not to be?',
];

//new words not in the dictionary
$newWords = [
    'rubbish'=> '-1.5',
    'mediocre' => '-1.0',
    'agressive' => '-0.5'
];

//Dynamically update the dictionary with the new words
$sentiment->updateLexicon($newWords);

//Print results
foreach ($strings as $string) {
    // calculations:
    $scores = $sentiment->getSentiment($string);
    // output:
    echo "String: $string\n";
    print_r(json_encode($scores));
    echo "";
}
```

### Advanced Outputs

[](#advanced-outputs)

```
Weather today is rubbish  ------------- {"neg":0.455,"neu":0.545,"pos":0,"compound":-0.3612}

This cake looks amazing  ------------- {"neg":0,"neu":0.441,"pos":0.559,"compound":0.5859}

His skills are mediocre  ------------- {"neg":0.4,"neu":0.6,"pos":0,"compound":-0.25}

He is very talented  ------------- {"neg":0,"neu":0.457,"pos":0.543,"compound":0.552}

She is seemingly very agressive  ------------- {"neg":0.338,"neu":0.662,"pos":0,"compound":-0.2598}

Marie was enthusiastic about the upcoming trip. Her brother was also passionate about her leaving - he would finally have the house for himself.  ------------- {"neg":0,"neu":0.761,"pos":0.239,"compound":0.765}

String: To be or not to be?  ------------- {"neg":0,"neu":1,"pos":0,"compound":0}

```

### Stargazers

[](#stargazers)

[![Stargazers repo roster for @davmixcool/php-sentiment-analyzer](https://camo.githubusercontent.com/356d55ecb3cb84e0d2a5c91bae0025d1f0c88b60ce83c9f6eabdc7416bbb74cd/68747470733a2f2f7265706f726f737465722e636f6d2f73746172732f6461766d6978636f6f6c2f7068702d73656e74696d656e742d616e616c797a6572)](https://github.com/davmixcool/php-sentiment-analyzer/stargazers)

### Forkers

[](#forkers)

[![Forkers repo roster for @davmixcool/php-sentiment-analyzer](https://camo.githubusercontent.com/ff457adea5cf7722d06aedb9b9866aeb980bb07b02e45c88d959d759485c9e03/68747470733a2f2f7265706f726f737465722e636f6d2f666f726b732f6461766d6978636f6f6c2f7068702d73656e74696d656e742d616e616c797a6572)](https://github.com/davmixcool/php-sentiment-analyzer/network/members)

### License

[](#license)

This package is licensed under the [MIT license](https://github.com/davmixcool/php-sentiment-analyzer/blob/master/LICENSE).

### Reference

[](#reference)

Hutto, C.J. &amp; Gilbert, E.E. (2014). VADER: A Parsimonious Rule-based Model for Sentiment Analysis of Social Media Text. Eighth International Conference on Weblogs and Social Media (ICWSM-14). Ann Arbor, MI, June 2014.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~187 days

Total

5

Last Release

2116d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5640065?v=4)[David Oti](/maintainers/davmixcool)[@davmixcool](https://github.com/davmixcool)

---

Top Contributors

[![davmixcool](https://avatars.githubusercontent.com/u/5640065?v=4)](https://github.com/davmixcool "davmixcool (25 commits)")[![heathdutton](https://avatars.githubusercontent.com/u/302215?v=4)](https://github.com/heathdutton "heathdutton (2 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (2 commits)")[![misa-neopix](https://avatars.githubusercontent.com/u/42573490?v=4)](https://github.com/misa-neopix "misa-neopix (1 commits)")

---

Tags

phpaisocialnlpmachine learningDeep learningSentiment Analyzer

### Embed Badge

![Health badge](/badges/davmixcool-php-sentiment-analyzer/health.svg)

```
[![Health](https://phpackages.com/badges/davmixcool-php-sentiment-analyzer/health.svg)](https://phpackages.com/packages/davmixcool-php-sentiment-analyzer)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.5M28](/packages/rubix-ml)[codewithkyrian/transformers

State-of-the-art Machine Learning for PHP. Run Transformers in PHP

758267.3k9](/packages/codewithkyrian-transformers)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

46688.8k5](/packages/deepseek-php-deepseek-php-client)[nlpcloud/nlpcloud-client

NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, tokenization, POS tagging, speech synthesis, embeddings, and dependency parsing. It is ready for production, served through a REST API. This is the PHP client for the API. More details here: https://nlpcloud.com. Documentation: https://docs.nlpcloud.com. Github: https://github.com/nlpcloud/nlpcloud-php

2526.3k1](/packages/nlpcloud-nlpcloud-client)[softcreatr/php-mistral-ai-sdk

A powerful and easy-to-use PHP SDK for the Mistral AI API, allowing seamless integration of advanced AI-powered features into your PHP projects.

1621.5k](/packages/softcreatr-php-mistral-ai-sdk)[softcreatr/php-perplexity-ai-sdk

A powerful and easy-to-use PHP SDK for the pplx (Perplexity) API, allowing seamless integration of advanced AI-powered features into your PHP projects..

1411.0k](/packages/softcreatr-php-perplexity-ai-sdk)

PHPackages © 2026

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