Skip to content

Repository files navigation

Tensor: A PHP Extension for Scientific Computing

PHP from Packagist Latest Stable Version Code Checks Downloads from Packagist GitHub

Scientific Computing for the PHP language.

Installation

Install the Tensor extension via PIE:

$ pie install rubix/tensor_ext

Requirements

Documentation

API documentation can be found in the docs folder in the project root.

Manually Compiling the Extension

Clone the repository locally using Git:

$ git clone https://github.com/RubixML/Tensor-Ext

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 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_ext.so

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

php -m | grep tensor_ext

Tip for Compiling on MacOS

To avoid some errors on Mac devices using homebrew, don't forget to add the following 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

Contributing

See CONTRIBUTING.md for guidelines.

License

The code is licensed MIT and the documentation is licensed CC BY-NC 4.0.

About

Scientific computing for the PHP language.

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages