kauffinger / pyman
A skeleton repository for my packages
Fund package maintenance!
kauffinger
Requires
- php: ^8.3.0
- illuminate/process: ^11.36
Requires (Dev)
- laravel/pint: ^1.18.1
- pestphp/pest: ^3.5.1
- pestphp/pest-plugin-type-coverage: ^3.1
- phpstan/phpstan: ^1.12.7
- rector/rector: ^1.2.8
- symfony/var-dumper: ^7.1.6
README
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.
Features
- 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
Requirements
- PHP 8.3+
- Python 3.x
- pip3
Installation
You can install the package via composer:
composer require kauffinger/pyman
Usage
use 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(); }
Requirements File
Create a requirements.txt
file in your specified Python environment directory:
requests==2.31.0
# Add other Python dependencies as needed
Error Handling
The 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
Testing
composer test
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.