kematjaya / backup-bundle
8.0.2
2026-03-10 22:50 UTC
Requires
- doctrine/collections: ^2.2|^3.0
- doctrine/persistence: ~2.0|^3.0|^4.1
- spatie/db-dumper: ^3.8|^4.0
- symfony/event-dispatcher: ^7.0|^8.0
- symfony/framework-bundle: ^7.0|^8.0
- symfony/yaml: ^7.0|^8.0
Requires (Dev)
- doctrine/doctrine-bundle: ^2.7|^3.2
- phpunit/phpunit: ^9.5
- symfony/browser-kit: ^7.0|^8.0
- symfony/var-dumper: ^7.0|^8.0
README
- installation
composer require kematjaya/backup-bundle
- setting
## config/packages/backup.yaml backup: name: postgresql location: '%kernel.project_dir%/var/backup'
- add route
# config/routes/annotations.yaml backup: resource: '@BackupBundle/Resources/config/routes.yaml'
/view-backup-file.html to view and download backup file - usage
php bin/console database:dump
- 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()); } }