Please, don't just put plain raw emails on your web pages. Bots are going to scrape your pages and fill all of our inboxes with spam emails.
Obfuscate emails and strings in PHP and Laravel to keep those nasty bots away from finding your email or worse, your users' emails.
This package uses different strategies to obfuscate clickable and non-clickable emails, so you can choose what suits your needs best.
You can install the package via composer:
composer require mokhosh/muddleYou can publish the config file with:
php artisan vendor:publish --tag="muddle-config"This is the contents of the published config file:
return [
/*
|--------------------------------------------------------------------------
| Default Strategy
|--------------------------------------------------------------------------
|
| Set default strategies for obfuscating text and email links
|
*/
'strategy' => [
'text' => \Mokhosh\Muddle\Strategies\Text\Random::class,
'link' => \Mokhosh\Muddle\Strategies\Link\Random::class,
],
];Optionally, you can publish the views using
php artisan vendor:publish --tag="muddle-views"In PHP Projects:
use Mokhosh\Muddle\Muddle;
use Mokhosh\Muddle\Strategies\Text;
use Mokhosh\Muddle\Strategies\Link;
$muddle = new Muddle(
text: new Text\Random,
link: new Link\Random,
);
$muddle->link('test@example.com');In Laravel Projects:
use Mokhosh\Muddle\Facades\Muddle;
use Mokhosh\Muddle\Strategies\Text;
use Mokhosh\Muddle\Strategies\Link;
// default strategy with facade
Muddle::text('test@example.com');
Muddle::link('test@example.com');
// specific strategy with facade
Muddle::strategy(text: new Text\Encrypt)->text('test@example.com')
Muddle::strategy(link: new Link\Encrypt)->link('test@example.com');{{-- default strategy components --}}
<x-muddle-link email="test@example.com" title="email" />
<x-muddle-text email="test@example.com" />
{{-- specific link strategy components --}}
<x-muddle-random email="test@example.com" title="email" />
<x-muddle-append email="test@example.com" title="email" />
<x-muddle-concatenation email="test@example.com" title="email" />
<x-muddle-encrypt email="test@example.com" title="email" />
<x-muddle-entities email="test@example.com" title="email" />
<x-muddle-hex email="test@example.com" title="email" />
<x-muddle-rotate email="test@example.com" title="email" />
{{-- specific text strategy components --}}
<x-muddle-text-random email="test@example.com" />
<x-muddle-text-append email="test@example.com" />
<x-muddle-text-concatenation email="test@example.com" />
<x-muddle-text-display-none email="test@example.com" />
<x-muddle-text-encrypt email="test@example.com" />
<x-muddle-text-entities email="test@example.com" />
<x-muddle-text-hex email="test@example.com" />
<x-muddle-text-rotate email="test@example.com" />composer test- Add Dusk tests
- Make loading components dynamic
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.