Pocus is a Python tool that simplifies PHP package management and execution. It automatically detects and installs the required PHP version based on composer.json requirements, downloads PHP packages, and provides an easy way to run bin scripts and PHP files.
- Automatic PHP Version Management: Detects required PHP version from composer.json and installs it
- Package Installation: Installs PHP packages using Composer
- Bin Script Execution: Runs bin scripts from installed packages
- GitHub Repository Support: Downloads and installs packages directly from GitHub URLs
- PHP File Execution: Runs PHP files using the installed PHP version
- Cross-Platform: Works on macOS, Linux, and Windows
- Multiple Architecture Support: Supports x86_64, arm64, and more
# Clone the repository
git clone https://github.com/pronskiy/pocus.git
cd pocus
# Install as a Python package (optional)
pip install -e .
# Install a package and its dependencies
python -m pocus phpstan/phpstan
# Run a bin script from an installed package
python -m pocus phpstan/phpstan phpstan analyse path/to/code
# Run a PHP file using the installed PHP version
python -m pocus phpstan/phpstan script.php arg1 arg2
# Install a package directly from GitHub
python -m pocus https://github.com/phpstan/phpstan
Pocus supports various version constraints in composer.json:
{
"require": {
"php": "^7.4|^8.0" // Will use PHP 8.0
}
}
- Pocus reads the PHP version requirement from composer.json
- It normalizes the PHP version to match available versions
- It downloads the appropriate PHP binary if it doesn't already exist
- It stores the PHP binary in ~/.pocus/{version}/
- It installs the requested package using Composer
- It executes bin scripts or PHP files as requested
~/.pocus/
├── downloads/ # Temporary storage for downloaded archives
└── {version}/ # Extracted PHP binaries for each version
└── php # PHP binary executable
- Python 3.6+
- Internet connection for downloading PHP binaries and packages
Contributions are welcome! Feel free to submit issues or pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.