NOTE: composer now includes an "outdated" command with similar functionality to CPVC, so this project will no longer be maintained.
Do you lock down your composer.json dependencies to a particular version for stability in your project, but often wonder if your dependencies are outdated?
This small application/library will check your composer.json file and output a table showing the latest version that will be installed based on your "require" statements, as well as the latest version of the package in the repository. You can then compare the versions and decide if you want to upgrade to the newer release.
There are online tools to check your dependencies as well, but those require your project to be hosted online or need to have a project file constantly uploaded to the service. CPVC can be run locally or integrated into your own application.
+-----------------------------+------------------+--------------------+
| Package | Required Version | Repository Version |
+-----------------------------+------------------+--------------------+
| * talisto/fake-repository | 1.0.1 | 2.0.0 |
| talisto/fake-dev-repository | 2.5.1 | 2.5.1 |
+-----------------------------+------------------+--------------------+
You can use this package as a library in your application, or a CLI app, or a web app.
For a quick install with Composer use:
$ composer require talisto/cpvc
Then in your application, use the following:
use Talisto\Composer\VersionCheck\Checker;
$checker = new Checker('/path/to/your/composer.json');
$result = $checker->checkAll();
The Checker()
constructor will take a Doctrine Cache object as the second
parameter to cache the lookup results:
use Talisto\Composer\VersionCheck\Checker;
use Doctrine\Common\Cache\FilesystemCache;
$cache = new FilesystemCache(sys_get_temp_dir());
$checker = new Checker('/path/to/your/composer.json', $cache);
$result = $checker->checkAll();
Alternatively you can use the setCache()
method to set the cache handler.
There is an output formatter class that will take the results and output an HTML table:
use Talisto\Composer\VersionCheck\Checker;
use Talisto\Composer\VersionCheck\Formatter\HTML as Formatter;
$checker = new Checker('/path/to/your/composer.json');
$formatter = new Formatter;
echo $formatter->render($checker->checkAll());
If you only want to check a subset of your dependencies:
use Talisto\Composer\VersionCheck\Checker;
use Talisto\Composer\VersionCheck\Formatter\HTML as Formatter;
$checker = new Checker('/path/to/your/composer.json');
$result = $checker->checkPackages(array('talisto/fake-repository'));
There are two ways to run the checker from the CLI. You'll need to run composer install
in the package root
to install the dependencies before running the scripts.
- php script:
php cli/cpvc.php
- phar archive:
cd build; php create_phar.php; chmod u+x cpvc.phar; ./cpvc.phar
The CLI script takes multiple parameters, run with -h
for help:
Usage:
cpvc [--no-dev] [--no-cache] [path]
Arguments:
path Path to composer.json
Options:
--no-dev Don't include dev dependencies.
--no-cache Don't cache the results.
--help (-h) Display this help message.
--quiet (-q) Do not output any message.
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug.
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.
There is a simple index.php script in the www
folder that will allow you to upload a composer.json
file through
a web browser. Just point your webserver to that folder.
Note: the web script is provided as a proof-of-concept and may not be suitable for public hosts.