pixovoid / packagist-version-checker
Laravel Artisan command to compare installed Composer package versions with Packagist and help update composer.json
Installs: 80
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/pixovoid/packagist-version-checker
Requires
- php: ^8.4
- composer/semver: ^3.4
- illuminate/support: ^12.41
- symfony/http-client: ^8.0
Requires (Dev)
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.8
- phpunit/phpunit: ^12.5
README
Artisan (Laravel) command to inspect Composer packages against Packagist and help update composer.json.
Features
- List installed packages and their installed versions
- Show latest versions available on Packagist
- Show which packages are outdated
- Propose updates to
composer.jsonand optionally runcomposer update
Installation
Require the package via Composer:
composer require pixovoid/packagist-version-checker
Quick setup for development
composer install composer test
Usage examples
- Check a single package:
php artisan packagist:check vendor/name
- Check all requirements from
composer.json:
php artisan packagist:check --composer
- Check installed packages (reads
composer.lock/vendor):
php artisan packagist:check --installed
- Show only outdated packages:
php artisan packagist:check --installed --outdated
- Propose updates to
composer.json(dry run):
php artisan packagist:check --composer --update --dry-run
- Apply updates to
composer.jsonand runcomposer update:
php artisan packagist:check --composer --update --apply
Options
--composer: Read packages from localcomposer.jsonrequire/require-dev--installed: Read installed packages fromcomposer.lockorvendor/composer--outdated: Show only packages that are outdated--include-prereleases: Consider prerelease tags (useLatest (any)for outdated checks)--update: Propose updates incomposer.json--update-all: Shortcut for--composer --update--apply: After updatingcomposer.json, runcomposer updateto install new versions--dry-run: Do not write changes tocomposer.json--no-dev: Excluderequire-devwhen reading/updating
Behaviour & notes
- The command compares installed/required versions with the latest stable versions on Packagist and proposes constraints using a
^<latest-stable>heuristic. - Pre-release tags (for example
1.2.3-beta) are treated conservatively and are not used to form constraints by default.- Use
--include-prereleasesto make the command consider prerelease tags when determining whether a package is "outdated" (it will compare against theLatest (any)column which may include prerelease tags). - Note: As of this release the
--include-prereleasesflag affects only the outdated detection and filtering. The--updateproposal logic still forms^<latest-stable>constraints by default. If you want updates proposed/applied based on prereleases too, enable that explicitly (I can add that behavior on request).
- Use
- The tool creates a timestamped backup of
composer.jsonbefore writing (e.g.composer.json.bak.20251231235959). - Network requests use a short timeout and a small retry/backoff strategy; Packagist responses are validated before use.
Requirements
- PHP:
^8.4
Dependencies
- Runtime:
illuminate/support(as declared incomposer.json) - Network and version handling:
symfony/http-client(used for Packagist requests) - Semver comparisons:
composer/semver(used when available for robust comparisons)
Development & testing
Install dependencies and run tests:
composer install composer test
To run the command locally while developing the package, register it in your application or run it from a Laravel app that includes this package via path repository.
Security & disclaimer
- This package is provided "as is" without warranties. Use at your own risk. The author and contributors are not liable for damages resulting from its use.
- Always review proposed
composer.jsonchanges and test them in a safe environment before applying to production. The command creates backups automatically.
Support & Contributing
Report issues or feature requests on GitHub: https://github.com/PixoVoid/packagist-version-checker/issues
Contributions are welcome. Please open pull requests against the main branch and follow the project's coding standards.
License
MIT — see the LICENSE file for details.
Implementation Notes
- HttpClient DI: The package binds
Symfony\Contracts\HttpClient\HttpClientInterfacein the service provider so theCheckPackagistcommand receives a client instance via constructor injection. This makes the command easy to test and lets applications provide custom HTTP client configuration. - Streaming & Memory: Packagist responses are read in a defensive way: the command checks the
Content-Lengthheader and streams responses in small chunks (with a hard safety limit of 1 MB) to avoid exhausting PHP memory. For environments that still encounter large compressed responses, the command temporarily raisesmemory_limitduring execution as a pragmatic fallback. - Atomic Writes: When proposing and applying
composer.jsonupdates the command creates a timestamped backup and uses a temp file + exclusive lock + atomicrename()to avoid corruptingcomposer.jsonon failure. - Semver policy: The default behavior is conservative — pre-release tags are ignored when forming
^<version>constraints. Handling for0.xpackages and configurable constraint policies are TODOs (see project TODO list). - Testing: Unit tests mock
HttpClientInterfaceand exercisefetchPackage()logic. Reflection-based access was replaced with a small test subclass to avoid PHP 8.5 deprecation warnings.
Debugging & Troubleshooting
- If you see an OOM (out-of-memory) error when running the command against many or very large packages, try running with a higher memory limit:
php -d memory_limit=512M artisan packagist:check --installed --outdated
- For verbose diagnostic output use the
-vflag. The command emits information about HTTP status, retry timing and when responses are skipped because they exceed the safety limit.
Publishing Notes
- Package name:
pixovoid/packagist-version-checker(updatecomposer.jsonauthor/description if required before publishing). - Recommended pre-publish checklist: run
composer test, add a GitHub Actions workflow to run tests on push/PR, and consider runningphpstanfor static checks.