1. Go to this page and download the library: Download helbrary/db-synchronizer 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/ */
helbrary / db-synchronizer example snippets
sh
// function for authorization
public function actionAuthenticateForDump($username, $password)
{
try {
$identity = $this->authenticator->authenticate( array( $username, $password ) );
if (in_array('admin', $identity->roles)) {
$this->dbSynchronizer->setAsAuthorized();
}
} catch (AuthenticationException $e) {
Debugger::log($e, Base::LOG_DIRECTORY_NAME);
}
$this->terminate();
}
public function actionDownloadDump($host, $username, $password, $db)
{
try {
$dump = $this->dbSynchronizer->dump($host, $username, $password, $db);
$fileResponse = new FileResponse($dump, 'dump.sql', 'application/sql', TRUE);
$this->presenter->sendResponse($fileResponse);
} catch (\Exception $e) {
Debugger::log($e, Base::LOG_DIRECTORY_NAME);
header("HTTP/1.0 404 Not Found");
}
$this->terminate();
}
sh
php index.php db --sync-local # for download remote dump and import to local db
php index.php db --backup-remote # for backup remote db, dump of db will be saved in temp/dumps directory of web
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.