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.6(2w ago)2112↓60%proprietaryPHPPHP &gt;=8.2CI passing

Since Apr 5Pushed 2w 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 4d ago

READMEChangelog (5)Dependencies (15)Versions (7)Used By (0)

Python packages in PHP
======================

[](#python-packages-in-php)

### 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 🐘

✅ 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)🔥 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.
See [syncfly/transformers-torch-php](https://github.com/SyncFly/transformers-torch-php) for a quick start with `transformers` and `torch`.

System requirements
-------------------

[](#system-requirements)

RequirementVersionPHP≥ 8.2OSLinux, macOS, WindowsArchitecturex86\_64, arm64The library automatically downloads and installs the [`uv`](https://docs.astral.sh/uv/) tool and a Python environment on first use. No manual Python installation is required.

> **Note for Windows users:** symlink creation may require Administrator privileges or Developer Mode enabled.

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

[](#installation)

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

Answer **yes** when Composer asks to activate the plugin. This will:

1. Download `uv` (~10 MB) into `vendor/bin/`
2. Create a Python virtual environment in `vendor/bin/python-in-php/`
3. Generate PHPDoc stubs for installed packages in `py/`

⭐️ Please star the repository to show that there is demand for it, so that you can be sure it will continue to be maintained

Quick start
-----------

[](#quick-start)

After installation, Python's standard library is available immediately:

```
