garryrodriguez/php-ai-classifier

Native PHP text classification library

Maintainers

Package info

github.com/garryRodriguez/php-ai-classifier

pkg:composer/garryrodriguez/php-ai-classifier

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-01-31 04:42 UTC

This package is auto-updated.

Last update: 2026-03-29 01:14:16 UTC


README

A lightweight, native PHP text classification library. Categorize support tickets, blog posts, or user feedback instantly without needing expensive external APIs like OpenAI or Python microservices.

Features

  • 100% Native PHP: No dependencies, no Python, no C++ extensions.
  • Fast & Private: All data stays on your server. Zero latency.
  • Easy Integration: Built for Composer and modern PSR-4 standards.
  • Naive Bayes Logic: Uses probability-based classification for reliable sorting.

Usage Example

use garryRodriguez\PhpAiClassifier\Classifier;

$ai = new Classifier();

// 1. Train the AI
$ai->train('billing', 'I need my invoice for last month');
$ai->train('billing', 'Where is my receipt?');
$ai->train('support', 'The app is crashing on my iPhone');
$ai->train('support', 'I cannot log in to my account');

// 2. Predict categories
$category = $ai->predict('Can you send me my bill?');

echo $category; // Outputs: billing


******

$ai = new Classifier();

// Only train if we don't have a saved model yet
if (!file_exists('my_model.json')) {
    $ai->train('billing', 'I need my invoice');
    $ai->saveModel('my_model.json');
} else {
    $ai->loadModel('my_model.json');
}

echo $ai->predict('Where is my bill?');

Installation

Install the package via Composer:

composer require garryrodriguez/php-ai-classifier

```zsh
composer require garryrodriguez/php-ai-classifier