php-composer-cli
v1.0.0
Published
PHP and Composer as npm CLI package — automatically downloads PHP binaries and Composer for the current platform
Maintainers
Readme
php-composer-cli
An npm CLI package that automatically downloads PHP and Composer for your current platform and exposes them as php and composer terminal commands.
Supported platforms
| OS | Arch | PHP binary source | |---------|-------|---------------------------------------------------------------------------------------------| | Linux | x64 | crazywhalecc/static-php-cli | | Linux | arm64 | crazywhalecc/static-php-cli | | macOS | x64 | crazywhalecc/static-php-cli | | macOS | arm64 | crazywhalecc/static-php-cli | | Windows | x64 | shivammathur/php-builder-windows |
PHP version is resolved from php/php-src releases.
Composer is resolved from composer/composer releases.
Installation
Global (recommended)
npm install -g php-composer-cliDuring install, the postinstall script automatically downloads the correct PHP binary and composer.phar into the package's dist/ folder.
Local (per-project)
npm install php-composer-cli
npx php --version
npx composer --versionUsage
After a global install:
# Check versions
php --version
composer --version
# Run a PHP script
php my-script.php
# Create a new Laravel project
composer create-project laravel/laravel my-app
# Install dependencies from composer.json
composer install
# Add a package
composer require guzzlehttp/guzzleProject structure
php-composer-cli/
├── bin/
│ ├── php.js # `php` CLI wrapper
│ └── composer.js # `composer` CLI wrapper
├── dist/ # Downloaded binaries (created at install time)
│ ├── php / php.exe
│ └── composer.phar
├── lib/
│ ├── github.js # GitHub Releases API helpers
│ ├── platform.js # Platform detection + version resolution via GitHub API
│ └── download.js # HTTP download + archive extraction
├── install.js # postinstall script
└── package.jsonHow it works
npm installtriggers thepostinstallscript (install.js).- The script detects the OS and CPU architecture.
- PHP version is resolved via the GitHub Releases API of the official php/php-src repository.
- PHP binary (precompiled static executable) is downloaded from GitHub releases — no build step required:
- Windows x64: shivammathur/php-builder-windows — official prebuilt NTS ZIPs
- Linux / macOS: crazywhalecc/static-php-cli — static builds compiled from php/php-src
- Composer (
composer.phar) is downloaded from composer/composer GitHub releases — the official Composer repository. - Both are placed in
dist/. bin/php.jsandbin/composer.jsare thin wrappers that delegate all CLI arguments viachild_process.spawnSync.
Updating PHP / Composer
To force a fresh download (e.g. after a new PHP or Composer release), delete dist/ and run npm install again:
rm -rf node_modules/php-composer-cli/dist
npm installVersions are always resolved dynamically from GitHub — no manual edits needed.
License
MIT
