spatie/email-concealer-cli
CLI tool to conceal email addresses in files by replacing their domains. Ideal for sanitizing production data like MySQL dumps before using them locally, so you can share or test with realistic data without storing real addresses.
user@example.com → user@fake-domain.com). This aligns well with data privacy, compliance (GDPR), and local development needs where real emails should not be exposed.schedule:run for automated obfuscation of sensitive files).spatie/email-concealer library (PHP) suggests this could be adapted into a Laravel service provider for programmatic obfuscation if CLI-only is limiting..sql, .txt, .md), which is useful for:
mysqldump --result-file=output.sql).spatie/email-concealer).user@sub.example.com vs. user@example.com).user%40example.com).fakerphp/faker for synthetic data)?fake data seeding)?admin@example.com should never be masked)?Str::obfuscateEmail()) be better for programmatic use?php artisan email:conceal database_dump.sql).// app/Console/Commands/ObfuscateEmails.php
use Spatie\EmailConcealer\EmailConcealer;
use Symfony\Component\Process\Process;
class ObfuscateEmails extends Command {
protected $signature = 'email:conceal {file}';
protected $description = 'Conceal emails in a file';
public function handle() {
$process = new Process(['php', 'vendor/bin/email-concealer', $this->argument('file')]);
$process->run();
$this->info($process->getOutput());
}
}
// app/Providers/EmailConcealerServiceProvider.php
class EmailConcealerServiceProvider extends ServiceProvider {
public function register() {
$this->app->singleton('email-concealer', function () {
return new EmailConcealer(config('email-concealer.domain'));
});
}
}
main.# .github/workflows/obfuscate.yml
- name: Obfuscate emails
run: php artisan email:conceal production_dump.sql
str_replace)..sql, .json, .md)..env).composer require spatie/email-concealer-cli --dev
config/email-concealer.php).php artisan email:conceal test.sql).fakerphp/faker or custom scripts if blocking issues arise.parallel command).fake data). Use for exported data only.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| PHP version incompatibility | Tool fails to run | Fork and update dependencies |
| Regex misidentifies emails | False positives/negatives | Test with edge cases; add validation |
| Large file crashes | Memory exhaustion | Process in chunks or use streaming |
How can I help you explore Laravel packages today?