Pyman is a PHP package that simplifies the management of Python dependencies in PHP applications. It's designed to help you seamlessly integrate Python scripts and libraries into your PHP projects by handling virtual environment setup and dependency management.
- Automatic Python virtual environment creation
- Python dependency management via
requirements.txt - Easy integration with Laravel's Process handling
- Robust error handling for common Python-related issues
- PHP 8.3+
- Python 3.x
- pip3
On Debian-based distros you might need python3.12-venv
You can install the package via composer:
composer require kauffinger/pymanuse Kauffinger\Pyman\PythonEnvironmentManager;
use Illuminate\Process\Factory;
// Initialize the manager with a base path for your Python environment
$manager = new PythonEnvironmentManager('/path/to/python/environment', new Factory());
// Set up the environment (creates venv and installs dependencies)
try {
$manager->setup();
} catch (PymanException $e) {
// Handle any setup errors
echo $e->getMessage();
}Create a requirements.txt file in your specified Python environment directory:
requests==2.31.0
# Add other Python dependencies as neededThe package throws PymanException in the following cases:
- Python3 or pip3 is not installed
- Failed to create the Python directory
- Missing requirements.txt file
- Failed to install Python dependencies
- Failed to create virtual environment
composer testPlease see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.