diff --git a/README.md b/README.md
index 53e51e4..aa5ecd1 100755
--- a/README.md
+++ b/README.md
@@ -46,8 +46,16 @@ if ($update->checkUpdate() === false)
// Check if new update is available
if ($update->newVersionAvailable()) {
+ echo 'New Version: ' . $update->getLatestVersion();
+ // Simulate or install?
+ $simulate = true;
//Install new update
- echo 'New Version: ' . $update->getLatestVersion();
+ $result = $update->update($simulate);
+ if ($result === true) {
+ echo 'Update simulation successful
';
+ } else {
+ echo 'Update simulation failed: ' . $result . '!
';
+ }
} else {
// No new update
echo 'Your application is up to date';
diff --git a/example/client/update/index.php b/example/client/update/index.php
index 7634cd1..6463833 100755
--- a/example/client/update/index.php
+++ b/example/client/update/index.php
@@ -13,36 +13,63 @@
// $update->setCache(new Desarrolla2\Cache\Adapter\File(__DIR__ . '/cache'), 3600);
//Check for a new update
-if ($update->checkUpdate() === false)
- die('Could not check for updates! See log file for details.');
+if ($update->checkUpdate() === false) {
+ die('Could not check for updates! See log file for details.');
+}
if ($update->newVersionAvailable()) {
- //Install new update
- echo 'New Version: ' . $update->getLatestVersion() . '
';
- echo 'Installing Updates:
';
- echo '
'; - var_dump(array_map(function($version) { - return (string) $version; - }, $update->getVersionsToUpdate())); - echo ''; - - // This call will only simulate an update. - // Set the first argument (simulate) to "false" to install the update - // i.e. $update->update(false); - $result = $update->update(); - if ($result === true) { - echo 'Update simulation successful
'; - var_dump($update->getSimulationResults()); - echo ''; - } - } + //Install new update + echo 'New Version: ' . $update->getLatestVersion() . '
'; + var_dump(array_map(function ($version) { + return (string) $version; + }, $update->getVersionsToUpdate())); + echo ''; + + // Optional - empty log file + $f = @fopen(__DIR__ . '/update.log', 'r+'); + if ($f !== false) { + ftruncate($f, 0); + fclose($f); + } + + // Optional Callback function - on each version update + function eachUpdateFinishCallback($updatedVersion) + { + echo '
'; + var_dump($update->getSimulationResults()); + echo ''; + } + } } else { - echo 'Current Version is up to date