PHP code example of kematjaya / backup-bundle
1. Go to this page and download the library: Download kematjaya/backup-bundle 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/ */
kematjaya / backup-bundle example snippets
php bin/console database:dump
// save log to database
namespace App\EventListener;
use App\Repository\BackupRepository;
use Kematjaya\BackupBundle\Event\AfterDumpEvent;
use Kematjaya\BackupBundle\Event\BackupEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Description of BackupEventListener
*
* @author apple
*/
class BackupEventListener implements EventSubscriberInterface
{
private BackupRepository $backupRepository;
public function __construct(BackupRepository $backupRepository)
{
$this->backupRepository = $backupRepository;
}
public static function getSubscribedEvents():array
{
return [
BackupEvents::AFTER_DUMP => "saveLog"
];
}
public function saveLog(AfterDumpEvent $evt):void
{
$this->backupRepository->create($evt->getFileName());
}
}