kematjaya/backup-bundle

Maintainers

Package info

github.com/kematjaya0/backup-bundle

pkg:composer/kematjaya/backup-bundle

Statistics

Installs: 803

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

8.0.2 2026-03-10 22:50 UTC

This package is auto-updated.

Last update: 2026-03-10 22:51:20 UTC


README

  1. installation
composer require kematjaya/backup-bundle
  1. setting
## config/packages/backup.yaml

backup:
    name: postgresql
    location: '%kernel.project_dir%/var/backup'
  1. add route
    # config/routes/annotations.yaml
    backup:
         resource: '@BackupBundle/Resources/config/routes.yaml'
    /view-backup-file.html to view and download backup file
  2. usage
    php bin/console database:dump
  3. insert event
    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());
        }
    }