PHP code example of shalvah / upgrader
1. Go to this page and download the library: Download shalvah/upgrader 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/ */
shalvah / upgrader example snippets
// Create a CLI `upgrade` command, where you call Upgrader
// Relative path to the config file in the user's project
$userOldConfigFile = 'config/my_library.php';
// Absolute path to a sample of the new config in your project
$sampleNewConfigFile = __DIR__ . '/../../config/my_library.php';
$upgrader = Upgrader::ofConfigFile($userOldConfigFile, $sampleNewConfigFile)
->move('path', 'static.path')
->dontTouch('ip_addresses');
// If this is a dry run, print the expected changes
if ($this->option('dry-run')) {
$changes = $upgrader->dryRun();
if (empty($changes)) {
$this->info("No changes needed! Looks like you're all set.");
return;
}
$this->info('The following changes will be made to your config file:');
foreach ($changes as $change) {
$this->info($change["description"]);
}
return;
}
// Otherwise, run the upgrade 🚀
$upgrader->upgrade();