PHP code example of kylekatarnls / update-helper

1. Go to this page and download the library: Download kylekatarnls/update-helper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kylekatarnls / update-helper example snippets


namespace MyNamesapace;

use UpdateHelper\UpdateHelper;
use UpdateHelper\UpdateHelperInterface;

class MyUpdateHelper implements UpdateHelperInterface
{
    public function check(UpdateHelper $helper)
    {
        $helper->write("You're using an obsolete version of my-super-package, consider upgrading to version 2 or greater.");

        if ($helper->hasAsDependency('laravel/framework') && $helper->isDependencyLesserThan('laravel/framework', '5.0.0')) {
            $helper->write("You're using a very old version or Laravel we don't support, please consider upgrading at least to 5.0.0.");
        }

        if ($helper->isInteractive()) {
            if ($helper->getIo()->askConfirmation('Do you want us to upgrade it for you?')) {
                $helper->setDependencyVersions(array(
                    'my-vendor/my-super-package' => '^2.0.0',
                    'laravel/framework' => '^5.0.0', // Skip it if not installed
                ))->update();
            }
        }
    }
}