PHPackages                             rubix/tensor - 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. rubix/tensor

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

rubix/tensor
============

A library and extension that provides objects for scientific computing in PHP.

3.0.5(2y ago)2751.4M—3%34[9 issues](https://github.com/RubixML/Tensor/issues)5MITPHPPHP &gt;=7.4CI failing

Since Oct 14Pushed 1mo ago9 watchersCompare

[ Source](https://github.com/RubixML/Tensor)[ Packagist](https://packagist.org/packages/rubix/tensor)[ Docs](https://github.com/RubixML/Tensor)[ GitHub Sponsors](https://github.com/andrewdalpino)[ RSS](/packages/rubix-tensor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (31)Used By (5)

Tensor: Scientific Computing for PHP
====================================

[](#tensor-scientific-computing-for-php)

[![PHP from Packagist](https://camo.githubusercontent.com/55eef0506205d3839f716c9241c275335b11f129b883977e0086a03455a3a012/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f72756269782f74656e736f722e7376673f7374796c653d666c617426636f6c6f72423d383839324246)](https://www.php.net/) [![Latest Stable Version](https://camo.githubusercontent.com/f57edca2f8562437098c7e47c93382cf97fa5242f0ae4a5602925e802ffc2631/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72756269782f74656e736f722e7376673f7374796c653d666c617426636f6c6f72423d6f72616e6765)](https://packagist.org/packages/rubix/tensor) [![Code Checks](https://github.com/RubixML/Tensor/actions/workflows/ci.yml/badge.svg)](https://github.com/RubixML/Tensor/actions/workflows/ci.yml) [![Extension Build](https://github.com/RubixML/Tensor/actions/workflows/ci-ext.yml/badge.svg)](https://github.com/RubixML/Tensor/actions/workflows/ci-ext.yml) [![Downloads from Packagist](https://camo.githubusercontent.com/d88705bb5d8dba934bfab7d1228f324480d0189fe54af814faf160a587fa97d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f72756269782f74656e736f722e7376673f7374796c653d666c617426636f6c6f72423d726564)](https://packagist.org/packages/rubix/tensor) [![GitHub](https://camo.githubusercontent.com/504a651a14c406b2cfa1da90c04020842cc7990a3055c8eb657f9f88d52765ed/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f52756269784d4c2f54656e736f72)](https://github.com/RubixML/Tensor/blob/master/LICENSE.md)

A library and extension that provides objects for scientific computing in [PHP](https://php.net).

Installation
------------

[](#installation)

Follow the instructions below to install either Tensor PHP or the Tensor extension.

### Tensor PHP

[](#tensor-php)

Install Tensor PHP into your project with [Composer](https://getcomposer.org/):

```
$ composer require rubix/tensor
```

### Tensor Extension

[](#tensor-extension)

Install the Tensor extension via [PECL](https://pecl.php.net/package/Tensor):

```
$ pecl install tensor
```

Compiling on MacOS : To avoid some errors on Mac devices using homebrew, don't forget to add environment variables:

```
export LDFLAGS="-L$(brew --prefix openblas)/lib -L$(brew --prefix pcre2)/lib -L$(brew --prefix gcc)/lib/gcc/current"
export CPPFLAGS="-I$(brew --prefix openblas)/include -I$(brew --prefix pcre2)/include -I$(brew --prefix gcc)/include"
export PKG_CONFIG_PATH="$(brew --prefix openblas)/lib/pkgconfig:$(brew --prefix pcre2)/lib/pkgconfig:$(brew --prefix gcc)/lib/pkgconfig"
export PATH="$(brew --prefix gcc)/bin:$PATH"
export FC=$(brew --prefix gcc)/bin/gfortran
```

> **Note:** If both the library and extension are installed, the extension will take precedence.

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

[](#requirements)

- [PHP](https://php.net) 8.0 or above

### Optional To Compile Extension

[](#optional-to-compile-extension)

- A C compiler such as [GCC](https://gcc.gnu.org/), [Clang](https://clang.llvm.org/), or [Visual C++](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads)
- A Fortran compiler such as [GFortran](https://gcc.gnu.org/wiki/GFortran)
- The PHP development package (source code and tooling)
- [OpenBLAS](https://www.openblas.net/) development package
- [LAPACKE](https://www.netlib.org/lapack/lapacke.html) C interface to [LAPACK](http://www.netlib.org/lapack/)
- [re2c](https://re2c.org/) 0.13.6 or later
- [GNU make](https://www.gnu.org/software/make/) 3.81 or later
- [autoconf](https://www.gnu.org/software/autoconf/autoconf.html) 2.31 or later
- [automake](https://www.gnu.org/software/automake/) 1.14 or later
- Ubuntu build-essentials

Manually Compiling the Extension
--------------------------------

[](#manually-compiling-the-extension)

Clone the repository locally using [Git](https://git-scm.com/):

```
$ git clone https://github.com/RubixML/Tensor
```

Make sure you have all the necessary build tools installed such as a C compiler and make tools. For example, on an Ubuntu linux system you can enter the following on the command line to install the necessary dependencies.

```
$ sudo apt-get install make gcc gfortran php-dev libopenblas-dev liblapacke-dev re2c build-essential
```

Then, change into the `ext` directory from the project root and run the following commands from the terminal. See [this guide](https://www.php.net/manual/en/install.pecl.phpize.php) for more information on compiling PHP extensions with PHPize.

```
$ cd ./ext
$ phpize
$ ./configure
$ make
$ sudo make install
```

Finally, add the following line to your `php.ini` configuration to install the extension.

```
extension=tensor.so

```

To confirm that the extension is loaded in PHP, you can run the following command.

```
php -m | grep tensor
```

Performance Comparison
----------------------

[](#performance-comparison)

[![Tensor Performance MNIST](https://raw.githubusercontent.com/RubixML/Tensor/master/docs/images/tensor-performance-mnist.png)](https://raw.githubusercontent.com/RubixML/Tensor/master/docs/images/tensor-performance-mnist.png)

[![Tensor Performance Benchmarks](https://raw.githubusercontent.com/RubixML/Tensor/master/docs/images/tensor-performance-benchmarks.png)](https://raw.githubusercontent.com/RubixML/Tensor/master/docs/images/tensor-performance-benchmarks.png)

Contributing
------------

[](#contributing)

See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

License
-------

[](#license)

The code is licensed [MIT](LICENSE) and the documentation is licensed [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/).

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance58

Moderate activity, may be stable

Popularity59

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 96.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 ~68 days

Recently: every ~216 days

Total

30

Last Release

794d ago

Major Versions

1.0.4 → 2.0.0-beta2019-11-14

2.2.3 → 3.0.0-beta2021-05-25

PHP version history (3 changes)1.0.0PHP &gt;=7.1.3

2.0.1PHP &gt;=7.2

3.0.0-betaPHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/643b22cfe15a5f3ff42dc06ce98f1e5024b6e4578fc9627a058097f5046164d8?d=identicon)[andrewdalpino](/maintainers/andrewdalpino)

---

Top Contributors

[![andrewdalpino](https://avatars.githubusercontent.com/u/18690561?v=4)](https://github.com/andrewdalpino "andrewdalpino (313 commits)")[![mlocati](https://avatars.githubusercontent.com/u/928116?v=4)](https://github.com/mlocati "mlocati (7 commits)")[![27pchrisl](https://avatars.githubusercontent.com/u/6286310?v=4)](https://github.com/27pchrisl "27pchrisl (1 commits)")[![LouisAUTHIE](https://avatars.githubusercontent.com/u/65625876?v=4)](https://github.com/LouisAUTHIE "LouisAUTHIE (1 commits)")[![villfa](https://avatars.githubusercontent.com/u/2891564?v=4)](https://github.com/villfa "villfa (1 commits)")[![cmb69](https://avatars.githubusercontent.com/u/2306138?v=4)](https://github.com/cmb69 "cmb69 (1 commits)")[![Aweptimum](https://avatars.githubusercontent.com/u/40273116?v=4)](https://github.com/Aweptimum "Aweptimum (1 commits)")

---

Tags

arithmeticengineeringlapacklinear-algebramachine-learningmathmatrixmatrix-decompositionsmatrix-factorizationsmatrix-multiplicationmultithreadedphpphp-extensionrubixscientific-computingstatisticstensortensor-extensiontensor-phpvectorphpvectormatrixmatharithmeticextensionsvdstatisticsphp-extensionlinear algebracomputingconvolutiontensoreigenvalueeigenvectormultithreadedcomputationtrigonometryengineeringdecompositionscientific computingsingular value decompositioneigendecompositionmatmulmatrix multiplicationsignal processing1d convolution2d convolutionblasdot productlapackvector normpseudoinverse

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/rubix-tensor/health.svg)

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

###  Alternatives

[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k7.1M40](/packages/markrogoyski-math-php)[sciphp/numphp

PHP library for scientific computing.

6618.9k](/packages/sciphp-numphp)[rindow/rindow-math-matrix

The fundamental package for scientific matrix operation

13281.5k7](/packages/rindow-rindow-math-matrix)

PHPackages © 2026

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