PHPackages                             mbeurel/php-liblinear - 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. mbeurel/php-liblinear

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

mbeurel/php-liblinear
=====================

Used the liblinear library with php

0.1.4(6y ago)334MITPHPPHP ^7.1

Since Nov 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mbeurel/php-liblinear)[ Packagist](https://packagist.org/packages/mbeurel/php-liblinear)[ Docs](https://github.com/mbeurel/php-liblinear)[ RSS](/packages/mbeurel-php-liblinear/feed)WikiDiscussions master Synced 1w ago

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

php-liblinear
=============

[](#php-liblinear)

[![Minimum PHP Version](https://camo.githubusercontent.com/4c62148864d567c4ee794ffab09c1dd4a3f45e41064bbb016440beddaae71a4d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e322d3838393242462e737667)](https://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/7a371f549cfc0932c4bce658af2b46239216fd0b723152d4c8760bdc26c6d110/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d62657572656c2f7068702d6c69626c696e6561722e737667)](https://packagist.org/packages/mbeurel/php-liblinear)[![Total Downloads](https://camo.githubusercontent.com/c8b955840937c72c8fd0e9b80c392b0ad4e3dbbc79ad514759c371a4e4009822/68747470733a2f2f706f7365722e707567782e6f72672f6d62657572656c2f7068702d6c69626c696e6561722f646f776e6c6f6164732e737667)](https://packagist.org/packages/mbeurel/php-liblinear)[![License](https://camo.githubusercontent.com/a0a654a039257e979d6442843924f90e89f44bd6fa1f3e3c60e7f6c67501b258/68747470733a2f2f706f7365722e707567782e6f72672f6d62657572656c2f7068702d6c69626c696e6561722f6c6963656e73652e737667)](https://packagist.org/packages/mbeurel/php-liblinear)

A simple, light and efficient short-text classification tool based on [Liblinear](https://www.csie.ntu.edu.tw/~cjlin/liblinear/) for PHP.

Inspired by Python Library [TextGrocery](https://github.com/2shou/TextGrocery).

For Lemmarizer words, used [php-lemmatizer](https://github.com/mbeurel/php-lemmatizer)

Installation Liblinear library
------------------------------

[](#installation-liblinear-library)

Debian or Ubuntu :

```
apt-get install liblinear-dev liblinear-tools liblinear3
```

Other distribution view [repository github](https://github.com/cjlin1/liblinear)

Install php-liblinear
---------------------

[](#install-php-liblinear)

You can install it with Composer:

```
composer require mbeurel/php-liblinear

```

Examples
--------

[](#examples)

Example scripts are available ina separate repository [php-liblinear/examples](https://github.com/mbeurel/php-liblinear/tree/master/exemple).

Sample Code
-----------

[](#sample-code)

```
include "vendor/autoload.php";
use PhpLiblinear\Classification\LibLinear;
$data = [
  ["French", "Ceci est un texte dans la langue française."],
  ["French", "Bonjour, comment allez vous ?"],
  ["French", "Bonjour, je m'appelle Jean !!!"],
  ["English", "This is a english language text."],
  ["English", "Hello, How are you ?"],
  ["English", "Hello, my name is Jean !!!"],
];
try {

  // Init library
  $libLinear = new LibLinear("instanceName", __DIR__."/var", array(
        "type"      =>  0,            // Liblinear type, view the liblinear documentation
        "cost"      =>  1.0,
        "epsilon"   =>  0.1,
        "debug"     =>  false
      )
    );

  // Liblinear train
  $libLinear->train($data);

  // Save model
  $libLinear->save();

  // Load model
  $libLinear->load();

  // Liblinear predict : String or Array parameters, to array => ["Bonjour, je m'appelle Louis", "Comment allez vous ?"]
  $result = $libLinear->predict("Bonjour, je m'appelle Louis");

  // View result
  var_dump($result);

  //  $result = array(
  //    0  =>  array(
  //      "value"        =>  "French",
  //      "percentage"   =>  0.763259,
  //      "percentages"  =>  array(
  //        "French"        => 0.763259,
  //        "English"       => 0.236741
  //      )
  //    )
  //  )

} catch(\Exception $e) {
  echo $e;
}
```

Credits
-------

[](#credits)

Created by [Matthieu Beurel](https://www.mbeurel.com). Sponsored by [Yipikai](https://yipikai.studio).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Total

3

Last Release

2212d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/36a40743e34f6405bba0274ff4819d47c68f759927fe050976e896e56c14adbd?d=identicon)[Matthieu Beurel](/maintainers/Matthieu%20Beurel)

---

Top Contributors

[![mbeurel](https://avatars.githubusercontent.com/u/439066?v=4)](https://github.com/mbeurel "mbeurel (13 commits)")

---

Tags

phpmachine learningLiblinear

### Embed Badge

![Health badge](/badges/mbeurel-php-liblinear/health.svg)

```
[![Health](https://phpackages.com/badges/mbeurel-php-liblinear/health.svg)](https://phpackages.com/packages/mbeurel-php-liblinear)
```

###  Alternatives

[rubix/ml

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

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

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

749231.8k5](/packages/codewithkyrian-transformers)[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).

138151.7k1](/packages/davmixcool-php-sentiment-analyzer)[niiknow/bayes

a machine learning lib

6950.0k](/packages/niiknow-bayes)

PHPackages © 2026

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