PComposer is a fast PHP package manager inspired by pnpm, designed to resolve Composer's drawback of having a global package directory. It uses a global package store to avoid re-downloading existing packages, making it much faster than traditional Composer installations.
- Global Package Store: Packages are stored globally and shared between projects
- Symbolic Links: Uses symbolic links in vendor directory to point to global store
- Composer.json Compatibility: Works with existing composer.json files
- Lock File Support: Uses
pcomposer.lockfor reproducible installations - Fast Installations: Avoids re-downloading packages that are already installed
- Disk Space Efficient: Multiple projects can share the same packages
- Familiar Commands: Uses the same command structure as Composer
Download the pre-built single-file executable:
# Download the latest version
curl -O https://github.com/your-repo/pcomposer/releases/download/v1.0.0/pcomposer-1.0.0.php
# Make executable
chmod +x pcomposer-1.0.0.php
# Use directly
./pcomposer-1.0.0.php installUse the platform-specific installers:
Unix/Linux/macOS:
curl -O https://github.com/your-repo/pcomposer/releases/download/v1.0.0/install.sh
chmod +x install.sh
./install.shWindows (Composer-style):
# One-liner installer (recommended)
php -r "copy('https://github.com/your-repo/pcomposer/releases/download/v1.0.0/installer.php', 'installer.php');" && php installer.php && del installer.phpNote: After installation, open a NEW command prompt/PowerShell window for the pcomposer command to be available.
-
Clone or download this repository
-
Run the installation script:
chmod +x install.sh ./install.sh
Or install manually:
chmod +x pcomposer sudo ln -s $(pwd)/pcomposer /usr/local/bin/pcomposer
- PHP 7.4 or higher
- PHP extensions:
zip,json,curl(orallow_url_fopenenabled) - Unix-like system (Linux, macOS) for symbolic links
# Install dependencies from composer.json
pcomposer install
# Update dependencies
pcomposer update
# Add a package
pcomposer require vendor/package
# Add a package with specific version
pcomposer require vendor/package "^1.0"
# Remove a package
pcomposer remove vendor/package
# List installed packages
pcomposer list
# Show package information
pcomposer show vendor/package
# Generate autoloader
pcomposer dump-autoload
# Clear global package cache
pcomposer clear-cache
# Show lock file information
pcomposer lock
# Remove lock file to force fresh install
pcomposer unlock
# Show version
pcomposer --version
# Show help
pcomposer --help-
Initialize a new project:
# Create composer.json manually or use existing one echo '{ "name": "my/project", "require": {} }' > composer.json pcomposer install
-
Add dependencies:
pcomposer require monolog/monolog pcomposer require symfony/http-foundation "^5.0" -
Install in existing project:
cd /path/to/your/project pcomposer install
PComposer uses a pcomposer.lock file to ensure reproducible installations across different environments. This is similar to Composer's composer.lock file.
Key Benefits:
- Reproducible Builds: Everyone gets the exact same versions
- Faster Installations: No need to resolve versions each time
- Team Consistency: All team members use identical dependencies
- CI/CD Reliability: Guarantees consistent deployments
Lock File Commands:
# View lock file information
pcomposer lock
# Remove lock file to force fresh version resolution
pcomposer unlock
# Install will automatically create/use lock file
pcomposer install
# Update will regenerate lock file with latest versions
pcomposer updateLock File Behavior:
pcomposer installuses locked versions if lock file exists and is up-to-datepcomposer installcreates new lock file if none existspcomposer updateremoves old lock file and creates new one with latest versionspcomposer unlockremoves lock file to force fresh dependency resolution
PComposer stores packages in a global directory (~/.pcomposer/store) similar to pnpm's store. When you install a package:
- PComposer checks if the package exists in the global store
- If not found, it downloads and stores it globally
- Creates a symbolic link in your project's
vendor/directory pointing to the global store - Multiple projects can share the same package files
Instead of copying packages to each project's vendor directory, PComposer creates symbolic links:
Your Project/
├── composer.json
├── vendor/
│ ├── monolog/ -> ~/.pcomposer/store/monolog/monolog/2.0.0
│ ├── symfony/ -> ~/.pcomposer/store/symfony/http-foundation/5.0.0
│ └── autoload.php
- Speed: No re-downloading of existing packages
- Disk Space: Shared packages across projects
- Consistency: Same package versions across projects
- Compatibility: Works with existing composer.json files
The global store is located at:
- Linux/macOS:
~/.pcomposer/store - Windows:
%USERPROFILE%\.pcomposer\store
PCOMPOSER_HOME: Override the home directoryPCOMPOSER_CACHE_DIR: Override the cache directory
| Feature | Composer | PComposer |
|---|---|---|
| Package Storage | Local to each project | Global shared store |
| Installation Speed | Downloads every time | Reuses existing packages |
| Disk Usage | Duplicates packages | Shares packages |
| Command Interface | composer |
pcomposer |
| Configuration | composer.json | composer.json (compatible) |
| Autoloader | Generated locally | Generated locally |
export PCOMPOSER_HOME=/custom/path
pcomposer install# Show detailed package info
pcomposer show monolog/monolog
# List all packages in global store
pcomposer list --global# Clear global cache
pcomposer clear-cache
# Show cache statistics
pcomposer stats-
Symbolic link permissions:
# Ensure you have permission to create symbolic links sudo chmod 755 /path/to/your/project -
Global store access:
# Check global store permissions ls -la ~/.pcomposer/store
-
Broken links:
# Repair broken symbolic links pcomposer repair-links
# Enable debug output
PCOMPOSER_DEBUG=1 pcomposer installpcomposer/
├── pcomposer # Main executable
├── src/ # Source code
│ ├── PComposer.php # Main class
│ ├── GlobalStore.php # Global package store
│ ├── PackageManager.php # Package downloading
│ ├── ComposerJsonParser.php # JSON handling
│ ├── VendorLinker.php # Symbolic link management
│ └── Utils.php # Utility functions
└── README.md
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
If you want to build PComposer from source or create your own distribution:
# Clone the repository
git clone https://github.com/your-repo/pcomposer.git
cd pcomposer
# Run the build script
php build.php
# The built files will be in the dist/ directory
ls -la dist/For detailed build information, see BUILD.md.
This project is open source and available under the MIT License.
- Inspired by pnpm for Node.js
- Compatible with Composer ecosystem
- Uses Packagist as the package registry
For issues, questions, or contributions, please open an issue on the GitHub repository.