PHP code example of bloggermohiuddin / updatecore
1. Go to this page and download the library: Download bloggermohiuddin/updatecore 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/ */
bloggermohiuddin / updatecore example snippets
define('GITHUB_REPO', 'your-username/your-repo');
define('GITHUB_TOKEN', 'ghp_your_personal_access_token');
pdateCore\Core\Updater;
$db = new PDO('mysql:host=localhost;dbname=your_db', 'user', 'pass');
$update = Updater::make($db, [
'repository' => GITHUB_REPO,
'github_token' => GITHUB_TOKEN,
]);
$result = $update->check();
if ($result['update_available']) {
echo "Update available!";
echo "From: {$result['current']['short_hash']}";
echo "To: {$result['latest']['short_hash']}";
}
$result = $update->execute();
if ($result['success']) {
echo "Update installed successfully!";
} else {
echo "Update failed: " . $result['error'];
}
Updater::make($db, $config)->execute();
// 2026_01_02_000002_add_profile_fields.php
return new class {
public function up(): void
{
$pdo = DB::connection()->getPdo();
$pdo->exec("ALTER TABLE users ADD COLUMN avatar VARCHAR(255) DEFAULT NULL");
}
public function down(): void
{
$pdo = DB::connection()->getPdo();
$pdo->exec("ALTER TABLE users DROP COLUMN avatar");
}
};
return new class {
public function up(): void
{
$pdo = DB::connection()->getPdo();
$pdo->exec("ALTER TABLE users ADD COLUMN phone VARCHAR(20)");
}
public function down(): void
{
$pdo = DB::connection()->getPdo();
$pdo->exec("ALTER TABLE users DROP COLUMN phone");
}
};
text
[2026-07-01 10:30:00] [INFO] Update started
[2026-07-01 10:30:01] [INFO] Checking for updates...
[2026-07-01 10:30:02] [INFO] Update available: abc123d → def456a
[2026-07-01 10:30:03] [INFO] Backup created: 20260701-abc123
[2026-07-01 10:30:05] [INFO] Downloading update...
[2026-07-01 10:30:10] [INFO] Extracting files...
[2026-07-01 10:30:15] [INFO] Running migrations...
[2026-07-01 10:30:20] [SUCCESS] Update completed successfully
updatecore/
├── composer.json
├── config/
│ └── config.example.php
├── src/
│ ├── Core/
│ │ └── Updater.php # Main orchestrator
│ ├── Github/
│ │ └── GithubClient.php # GitHub API client
│ ├── Backup/
│ │ └── BackupService.php # Backup & restore
│ ├── Replace/
│ │ └── ReplaceService.php # File replacement
│ ├── Migration/
│ │ ├── MigrationRunner.php # SQL & PHP migrations
│ │ └── MigrationRepository.php # Migration tracking
│ ├── Security/
│ │ └── SecurityGuard.php # Auth, CSRF, locks
│ └── Support/
│ ├── Config.php # Configuration
│ ├── Logger.php # Dual logging (file + DB)
│ └── Helpers.php # Utility functions
└── README.md