PHPackages                             syncfly/python-in-php - 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. syncfly/python-in-php

ActiveComposer-plugin[Utility &amp; Helpers](/categories/utility)

syncfly/python-in-php
=====================

"Python-In-PHP" allows you to use any Python packages directly in PHP, as if they were native PHP classes. This PHP-Python bridge comes with built-in package manager, which is integrated directly into Composer

0.8.1(2mo ago)247↓81.8%proprietaryPHPPHP &gt;=8.2

Since Apr 5Pushed 2mo agoCompare

[ Source](https://github.com/SyncFly/python-in-php)[ Packagist](https://packagist.org/packages/syncfly/python-in-php)[ RSS](/packages/syncfly-python-in-php/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

> ⏳ The project is currently under active development. It is still in the alpha stage, but it is already working.
> ⭐️ Star the repository to support the project and follow us

#### Python-in-PHP

[](#python-in-php)

The **Python-in-PHP** library allows you to easily use any Python packages as if they were native PHP packages 🐘

🔥 Fully use artificial intelligence frameworks for AI models inference or training directly in PHP!
You can run AI models with libraries like `transformers`, `torch`, `vllm`, `numpy`, etc. in your PHP project with PHP syntax.

✅ Environment with Python is installed automatically with Composer.

✅ Any Python packages are installed via Composer with a built-in package manager.

✅ Automatic PHPDoc generation for code completion in IDEs for any Python packages.

[![Python-in-PHP](image.png)](image.png)### Installation

[](#installation)

```
composer require syncfly/python-in-php
```

You need to answer "yes" when prompted to activate the plugin.

### Documentation

[](#documentation)

You can find the documentation here: (coming soon)

### Package manager

[](#package-manager)

The `Python-in-PHP Package Manager` is a built-in package manager based on `uv` that allows you to install and manage Python packages.

#### Intsall a package

[](#intsall-a-package)

`composer pip install `

#### Uninstall a package

[](#uninstall-a-package)

`composer pip uninstall `

#### Upgrade a package

[](#upgrade-a-package)

`composer pip install --upgrade `

### Examples

[](#examples)

Look at an example of using `transformers` and `torch` in PHP for running an AI model:

```
