code-rhapsodie/ezautosave-bundle
Installation
composer require code-rhapsodie/ezautosave-bundle
Register the bundle in config/bundles.php before EzSystems\EzPlatformAdminUiBundle:
CodeRhapsodie\EzAutosaveBundle\CodeRhapsodieEzAutosaveBundle::class => ['all' => true],
First Use Case
localStorage (client-side only).Content Creation/Editing
localStorage for that content.Customization Points
config/packages/ez_autosave.yaml to exclude specific content types:
code_rhapsodie_ez_autosave:
excluded_content_types: ['blog:post', 'custom:form']
CodeRhapsodie\EzAutosaveBundle\Storage\StorageInterface for server-side persistence (e.g., database).Event Listeners
ez_autosave.save: Trigger custom logic when autosaving (e.g., log drafts).
// services.yaml
App\EventListener\AutosaveListener:
tags:
- { name: kernel.event_listener, event: ez_autosave.save, method: onAutosave }
ez_autosave.restore: Validate/restructure restored data before applying it.Testing
localStorage in PHPUnit:
$this->getContainer()->get('ez_autosave.storage')->setData('key', $data);
Browser-Specific Behavior
localStorage is not shared across tabs/browsers. Warn users to use the same browser for autosave consistency.Content Type Mismatches
Performance
localStorage. Monitor size with:
console.log(localStorage.getItem('ez_autosave_<content_id>')?.length);
Debugging
$this->get('ez_autosave.storage')->clear();
bin/console debug:event-dispatcher | grep ez_autosave
Visual Feedback
ez_autosave.save event to trigger a toast notification via JavaScript:
document.addEventListener('ezAutosaveSaved', (e) => {
alert('Draft saved!');
});
Server-Side Fallback
localStorage to a database on form submission:
// src/Storage/DatabaseStorage.php
class DatabaseStorage implements StorageInterface {
public function save($key, $data) {
// Save to DB + localStorage
parent::save($key, $data);
$this->db->saveDraft($key, $data);
}
}
Multi-User Environments
Configuration Quirks
# config/packages/security.yaml
access_control:
- { path: ^/admin/content/edit, roles: ROLE_EDITOR }
How can I help you explore Laravel packages today?