- Does spatie/email-concealer-cli work with Laravel projects, or is it standalone?
- This package is standalone with no Laravel dependencies, but you can integrate it into Laravel workflows via Artisan commands, CI/CD pipelines, or scheduled tasks. It’s ideal for processing files like MySQL dumps or logs before using them in local Laravel environments.
- How do I install spatie/email-concealer-cli for Laravel?
- Install it globally via Composer: `composer global require spatie/email-concealer-cli`. Then use the `email-concealer` command in your Laravel project’s file paths. For tighter integration, wrap it in a custom Artisan command or service provider.
- Can I use this to obfuscate emails in a MySQL dump before importing into Laravel Homestead/Valet?
- Yes. Run `email-concealer conceal dump.sql` to replace domains (e.g., `user@example.com` → `user@fake-domain.com`). Output to a new file or pipe directly to `mysql` for safe local imports. It’s perfect for GDPR-compliant local dev setups.
- Will this break Laravel’s email validation or authentication if I use it on user data?
- No, it only replaces email domains, leaving local parts (e.g., `user@`) intact. However, avoid using it on active user tables—it’s designed for static files like dumps or documentation. For testing, consider Laravel’s `Faker` or `factory` for synthetic data.
- Does spatie/email-concealer-cli support PHP 8.1+ and Laravel 10?
- The package’s last update was in 2017, so it may not natively support PHP 8.1+. Test compatibility first or fork the repo to update dependencies. For Laravel 10, ensure your project’s PHP version is compatible with the underlying `spatie/email-concealer` library.
- How can I automate this for Laravel deployments (e.g., obfuscate logs before staging)?
- Add it to your CI/CD pipeline (e.g., GitHub Actions) or Laravel’s `post-deploy` hooks. Example: `php artisan email:conceal /path/to/logs.txt`. For scheduled tasks, use Laravel’s `schedule:run` with a custom command wrapping the CLI tool.
- Can I customize the replacement domain (e.g., use `example.com` in staging, `fake.com` in dev)?
- No, the CLI tool uses a static default domain. For dynamic domains, wrap it in a Laravel service provider or Artisan command to read from `config('email-concealer.domain')` and pass it via environment variables or config files.
- What if the tool misidentifies emails (e.g., `user@sub.example.com` or encoded emails like `user%40example.com`)?
- The tool may miss edge cases like subdomains or URL-encoded emails. Test thoroughly with your data. For stricter control, pre-process files with regex or use a Laravel-specific solution like `Str::of($email)->replaceDomain('fake.com')` for programmatic use.
- Is there a Laravel-specific alternative to this CLI tool?
- For programmatic obfuscation, consider the underlying `spatie/email-concealer` library (PHP) or build a custom Laravel helper using `Str::replaceFirst('@', '@fake.com', $email)`. The CLI is best for batch file processing, while Laravel helpers suit real-time masking.
- How do I validate that all emails were correctly obfuscated in a large file (e.g., 1GB SQL dump)?
- Manually inspect a sample or write a script to compare original vs. obfuscated files for email patterns. For automated testing, use PHPUnit to assert email replacements in smaller test files. Note: Large files may require optimizations or chunked processing.