PHP code example of placebook / framework-selfupdate
1. Go to this page and download the library: Download placebook/framework-selfupdate 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/ */
placebook / framework-selfupdate example snippets
use Placebook\Framework\Core\Install\SelfUpdate;
SelfUpdate::$installDir = ROOT . '/install';
namespace Placebook\Framework\Core\Install;
SelfUpdate::$installDir = ROOT . '/install';
SelfUpdate::updateDbIfLessThen('6.0.0'); // update to a specific version
SelfUpdate::updateDbIfLessThen(SelfUpdate::getMaxVersion()); // upgrade to maximum version
// updateDbIfLessThen updates only upwards. If you need to roll back down, there is another method for this:
$current = SelfUpdate::getDbVersion();
SelfUpdate::updateFromTo($current, '0.0.7'); // update that will work up and down (downgrade)
namespace Placebook\Framework\Core\Install;
use Exception;
use cri2net\php_pdo_db\PDO_DB;
class Migration_sample implements MigrationInterface
{
public static function up()
{
$pdo = PDO_DB::getPDO();
try {
$pdo->beginTransaction();
// something useful
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
throw $e;
}
}
public static function down()
{
$pdo = PDO_DB::getPDO();
try {
$pdo->beginTransaction();
// Rollback update
$pdo->commit();
} catch (Exception $e) {
$pdo->rollBack();
throw $e;
}
}
}
namespace Placebook\Framework\Core\Install;
use Exception;
// kernel update
SelfUpdate::$installDir = PROTECTED_DIR . '/install';
// data about modules for updating
$modules = [
['vendor' => 'vendor1', 'name' => 'package1'],
['vendor' => 'vendor2', 'name' => 'package2'],
];
try {
foreach ($modules as $module) {
try {
$versionsDir = PROTECTED_DIR . "/vendor/{$module['vendor']}/" . $module['name']; // path to vendor folder
$versions = SelfUpdate::getVersions($versionsDir); // get package versions
$max = SelfUpdate::getMaxVersion($versions); // get max version
SelfUpdate::updatePackage($max, $versionsDir, $module['vendor'], $module['name']); // update
} catch (Exception $e) {
}
}
SelfUpdate::updateDbIfLessThen(SelfUpdate::getMaxVersion());
} catch (Exception $e) {
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.