kylekatarnls/update-helper
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
The kylekatarnls/update-helper is an invaluable tool that allows developers to facilitate update or upgrade instructions for users of their library. This package extends the utility of dependency management, particularly for those managing their own custom libraries or using third-party ones. It not only alerts the user that they have an outdated version of the library, but can generate prompts to guide them through upgrading to a more current version.
Utilizing the kylekatarnls/update-helper package requires a few steps with PHP code and adjustments to your project's composer.json file. First, you'll need to add it as a requirement in the composer.json
file:
"require": {
"kylekatarnls/update-helper": "^1"
},
Following that, in your composer.json
file's scripts section, you'll instruct composer to check for updates after an autoload dump.
"scripts": {
"post-autoload-dump": [
"UpdateHelper\\UpdateHelper::check"
]
},
Then, you need to write a PHP class implementing UpdateHelperInterface
, which will include the update rules. An example of such a class would look like:
namespace MyNamespace;
use UpdateHelper\UpdateHelper;
use UpdateHelper\UpdateHelperInterface;
class MyUpdateHelper implements UpdateHelperInterface
{
public function check(UpdateHelper $helper)
{
$helper->write("You're using an old version of my-package, please consider upgrading.");
if ($helper->isInteractive()) {
if ($helper->getIo()->askConfirmation('Do you want us to upgrade it for you?')) {
$helper->setDependencyVersions([
'my-vendor/my-package' => '^2.0.0'
])->update();
}
}
}
}
In this PHP code, the check
method prints a message stating that an older version of the package is in use, and if running in an interactive mode, it asks for user confirmation to perform the upgrade. Upon confirmation, it sets the new version and executes the update.
Please remember to replace MyNamespace
and my-package
with the correct values for your project.
The documentation for the kylekatarnls/update-helper can be found directly within the repositor's README file on GitHub. It provides a comprehensive guide on the package's installation, usage, and configuration. To access the docs, pull the repository from https://github.com/kylekatarnls/update-helper.git and open the README file.