Add an official API binding for PHP alongside PHP-ML support (complete with examples and setup guide)

I desperately need access to a model from Hugging Face for my website. The whole thing is written in PHP; I even tried getting it to interoperate with a Python script (using Hugging Face’s transformer library), but that just didn’t work at all (note that the Python script itself DID work, but I just had trouble getting the results through PHP). As I last resort, I downloaded a third-party binding for PHP, but it was unmaintained and no version of it I could find worked. This is the ONLY PHP library I could find that supports the Hugging Face API.

I wish there was a version of the Hugging Face API that worked as well as the JS or Python version. I also wish there was a way to download and run the models locally through the transformer library on my server like is possible through PyTorch (supposedly using the PHP-ML library in place of PyTorch).


Hello. I wrote a PHP library just for that. It’s still in it’s early stages but you can check to see if the task you want is currently supported. The API is similar to the python and Javascript counterparts.

Check it out here: GitHub - CodeWithKyrian/transformers-php: Transformers PHP is a toolkit for PHP developers to add machine learning magic to their projects easily.

1 Like