adgoal/cleaner-bundle
Symfony bundle integrating lamoda/cleaner. Configure DB and custom storage cleaners via YAML, including transactional mode, parameters, and multi-query setups. Provides a console command to run all cleaners or a selected one (cleaner:clear).
adgoal/cleaner-bundle) is a Symfony wrapper for lamoda/cleaner, designed to clear stale data from databases, queues, or other storage layers. This aligns well with Laravel/PHP applications needing scheduled cleanup (e.g., logs, old records, temporary data) to optimize performance and storage.symfony/flex or manual integration).lamoda/cleaner library (PHP-based) could be directly integrated into Laravel, bypassing the bundle layer.DELETE FROM logs WHERE created_at < NOW() - INTERVAL '30 days')..env or config/cleaner.php.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony Bundle in Laravel | High | Use lamoda/cleaner library directly or wrap in a Laravel service. |
| Database Locking | Medium | Test with transactional: false to avoid deadlocks. |
| Query Safety | High | Validate SQL queries before production use. |
| Lack of Maintenance | Medium | Fork or maintain a Laravel-compatible version. |
| Performance Impact | Low | Schedule cleanups during off-peak hours. |
lamoda/cleaner directly.softDeletes, scheduled jobs)?
scheduler, or manual)?lamoda/cleaner (PHP) over the Symfony bundle to avoid DI conflicts.class CleanerService {
public function __construct(private Cleaner $cleaner) {}
public function pruneLogs(int $days): void {
$this->cleaner->delete('logs', "created_at < NOW() - ($days || ' days')::interval");
}
}
queue:prune commands.lamoda/cleaner directly in a Laravel app.$cleaner = new \Lamoda\Cleaner\DB\Cleaner($pdo);
$cleaner->delete('failed_jobs', "created_at < NOW() - INTERVAL '7 days'");
schedule:run or cron:
// app/Console/Kernel.php
$schedule->command('cleaner:run')->dailyAt('2:00');
| Component | Compatibility Notes |
|---|---|
| Laravel 8/9/10 | High (PHP 7.4+ required). |
| Database | PostgreSQL/MySQL/SQLite (via PDO). No native support for MongoDB/Redis. |
| Queues | Works with DBAL queues; Laravel’s queue drivers need custom adapters. |
| Caching | Not natively supported; extend for Redis/Memcached. |
| Symfony Bundle | Avoid unless using Symfony + Laravel hybrid (e.g., API Platform). |
config/cleaner.php (easy to modify).\Log::info('Cleanup executed', ['query' => $query, 'affected' => $affectedRows]);
lamoda/cleaner upstream.LIMIT clauses for large tables (e.g., DELETE FROM logs WHERE ... LIMIT 1000).created_at columns are indexed for faster queries.transactional: false unless required.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Accidental data deletion | Data loss | Dry-run mode (SELECT instead of DELETE). |
| Query syntax errors | Job failure | Validate SQL before execution. |
| Database locks | Performance degradation | Use transactional: false. |
| Unmonitored failures | Undetected issues | Log and alert on failures. |
| Schema changes | Broken queries | Test in staging before production. |
lamoda/cleaner basics.DELETE without backups).laravel-horizon for queues).How can I help you explore Laravel packages today?