Library / SDK
RubixML/ML avatar
RubixML/ML

Rubix ML: a machine learning library for PHP applications

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

2,209 stars193 forksPHPMIT

At a glance

What is it?
Rubix ML brings over 40 supervised and unsupervised learning algorithms into PHP through a Composer package. It fits teams whose data and deployment already live in PHP, and it is the wrong tool for large-scale deep learning work.
Who is it for?
Adopt Rubix ML when your application, data pipeline and deployment are already PHP and you need classification, regression, clustering or anomaly detection inside that runtime; the MIT licence and Composer install keep the cost of trying it low. Do not adopt it for large-scale deep learning work, where the README points to the Tensor extension for fast Matrix/Vector computing rather than claiming production GPU training.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 30, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What Rubix ML solves for PHP teams

Most machine learning libraries assume Python. A PHP shop that wants a churn score, a price estimate or a cluster label has two unappealing options: export data to a Python service and operate a second runtime, or hand-roll statistics that nobody maintains. Rubix ML closes that gap. It is a Composer package that runs inside the PHP process you already deploy, so a prediction call is a function call rather than a network hop to another service.

The audience is narrow and identifiable. You already have PHP 7.4 or above, your training data arrives as CSV, a database row set or PHP arrays, and your model is small enough to train on the same machine that serves requests. The README lists example projects that map to exactly these jobs: a credit default risk predictor, a customer churn predictor, a housing price predictor, a text sentiment analyzer. Classification, regression, clustering and anomaly detection are the topics the repository advertises. If your problem is one of those four and your data fits in memory, the library is aimed at you.

How the library is put together

The repository is a conventional PHP library layout: src/ holds the implementation, tests/ holds the test suite, docs/ and mkdocs.yml drive the documentation site, and benchmarks/ with phpbench.json.dist holds the performance harness. Static analysis and style are pinned through phpstan.neon, .phplint.yml and .php-cs-fixer.dist.php, and phpunit.xml configures the tests. That structure tells you what kind of project this is: a library with a maintained CI gate, not a collection of scripts.

The README describes the scope as the whole life cycle, from ETL through preprocessing, training, cross-validation and production use. The algorithms are grouped as supervised and unsupervised learners, which is the standard split: supervised learners take labelled samples, unsupervised learners work on unlabelled ones. Dataset objects carry the samples, transformers handle preprocessing, and cross-validation is a first-class concern rather than something you assemble yourself. The README also points at a separate Tensor extension for fast Matrix/Vector computing. That is the performance story, and it is deliberately optional: without it you get a pure-PHP path, with it you get a compiled backend. The README does not quantify the difference, so treat any speed expectation as something you measure on your own workload.

Installing Rubix ML and training a first model

Installation is a single Composer command. The README requires PHP 7.4 or above.

bash
composer require rubix/ml

After that, Composer writes the dependency into your project and autoloads the namespace. The README's recommended companion is the Tensor extension for fast Matrix/Vector computing, and it lists GD for image support, Mbstring for multibyte strings, the SVM extension for the libsvm engine, PDO for relational database support, and GraphViz for graph visualization as optional. None of those are needed for a first run.

A first real use is a supervised learner over labelled rows. The README does not print a training snippet, so the honest starting point is the basic introduction in the documentation plus one of the official example projects, which the README says come with instructions and a pre-cleaned dataset. Pick the one closest to your problem (the Iris flower classifier is the smallest) and read its bootstrap file, because that is where the library's actual call sequence is shown.

bash
composer require rubix/ml
php example.php

The Iris, Titanic and Housing projects are the smallest of the listed examples, so they are the cheapest way to confirm that your PHP build, autoloader and extensions are wired correctly before you point the library at your own data. Expect the example to load a dataset, split it, train a learner and report a score; if that runs, the environment is sound.

Where Rubix ML stops being the right tool

The README is explicit that Tensor is recommended for fast Matrix/Vector computing, which is a polite way of saying that pure-PHP numeric work has a ceiling. PHP arrays are not dense numeric buffers, and the language has no native GPU story in this package. If your model is a large neural network trained over many epochs on millions of rows, the training loop belongs in a framework built for that, and the README's example list (MNIST, CIFAR-10) shows the scale the project itself demonstrates, not the scale it targets.

The second boundary is deployment shape. Rubix ML runs in the same process as your application. That is the advantage for a churn score computed at request time, and a liability if training is long-running: a web request is the wrong place to fit a model. You need a worker, a queue job or a cron entry that writes the trained model somewhere the request path can load it. The README does not document a model registry, a rollback path or a serving format, so persistence and versioning are your responsibility. Treat that as a gap to plan around rather than a feature to discover later.

Rubix ML compared with scikit-learn

The obvious alternative is scikit-learn, and the difference is not algorithm count. scikit-learn lives in Python, so adopting it means a second runtime, a second deployment artifact and a serialization boundary between your PHP application and the model. Rubix ML removes that boundary entirely: the learner is a PHP object, the dataset is a PHP structure, and the prediction happens in the request that needs it. For a PHP monolith that wants one churn flag or one anomaly score, that is a smaller system.

The trade goes the other way on ecosystem and scale. scikit-learn sits in a Python environment with NumPy, pandas and the broader scientific stack, and it is the default choice when the team already writes Python or when the model is the product rather than a feature of a PHP app. Rubix ML's own answer to the numeric-performance question is the optional Tensor extension, which is a compiled PHP extension you have to install rather than a dependency that arrives with the package. Neither library is a deep learning framework, so if that is the actual requirement, look past both.

Maintenance, licence and upgrade cost

The repository is not archived, and the last push was on 2026-09-10. Recent releases are close together: 2.5.11 on 2026-08-30, 2.5.12 on 2026-09-06 and 2.5.13 on 2026-09-08. That release cadence means patch upgrades arrive often, and a Composer constraint that allows patch updates will pull them in without a code change. The CHANGELOG.md at the repository root is the place to read before bumping a minor version, because that is where behaviour changes would be recorded.

The licence is MIT for the code, which permits commercial use, and the README states the code is free to use commercially. The documentation is licensed separately under CC BY-NC 4.0, a non-commercial licence. That split matters if you intend to redistribute or adapt the docs themselves; it does not restrict using the library in a commercial product. This is a description of what the repository says, not legal advice, and anyone republishing documentation should read both licence files directly.

Editorial conclusion

Adopt Rubix ML when your application, data pipeline and deployment are already PHP and you need classification, regression, clustering or anomaly detection inside that runtime; the MIT licence and Composer install keep the cost of trying it low. Do not adopt it for large-scale deep learning work, where the README points to the Tensor extension for fast Matrix/Vector computing rather than claiming production GPU training. Before committing, verify that your PHP version is 7.4 or above, check whether the optional extensions your pipeline needs (GD, Mbstring, SVM, PDO) are available on your host, and run one of the official example projects end to end on your own data.

Frequently asked questions

Is machine learning the same as deep learning?

No. Deep learning is one family of machine learning models, and Rubix ML covers both: the README describes it as a machine learning and deep learning library with over 40 supervised and unsupervised learning algorithms.

Is machine learning full of coding?

Using Rubix ML does involve writing PHP. The library is installed with Composer and exposes learners, datasets and transformers as PHP objects, and the README points to tutorials and example projects that walk through a typical project.

Is machine learning a subset of deep learning?

No, the relationship runs the other way. Deep learning is a subset of machine learning, and Rubix ML treats them as one scope, offering supervised and unsupervised algorithms alongside deep learning support.

Is machine learning a branch of AI?

Machine learning is generally described as a branch of artificial intelligence. Rubix ML does not argue the taxonomy; it presents itself as a library for building programs that learn from data in PHP.

Official sources

  1. License: MIT
  2. Project website
  3. README
  4. Releases
  5. RubixML/ML on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/rubixml-ml.svg)](https://hysenlabs.com/projects/rubixml-ml)