New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

mokhosh/muddle

Obfuscate emails and strings in PHP and Laravel
14,330 81
Install
composer require mokhosh/muddle
Latest Version:v5.0.0
PHP:^8.2
Laravel:10 – 13
License:MIT
Last Updated:Aug 21, 2026
Links: GitHub  ·  Packagist
Maintainer: mokhosh

Muddle: Obfuscate, Obscure, Confuse, Jumble, Complicate, Perplex

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.

Installation

You can install the package via composer:

composer require mokhosh/muddle

Usage

In Laravel Projects:

{{-- instead of handing your emails to spammers like this: --}}
<a href="mailto:{{ $user->email }}">{{ $user->name }}</a>

{{-- do this: --}}
<x-muddle-link :email="$user->email" :title="$user->name" />

{{-- and we will confuscate the email in random ways to make it impossible for bots to steal your emails --}}

{{-- default strategy components based on config --}}
<x-muddle-link email="test@example.com" title="email" /> {{-- muddled email link --}}
<x-muddle-text email="test@example.com" /> {{-- muddled email text --}}

{{-- specific link strategy components --}}
<x-muddle-random email="test@example.com" title="email" /> {{-- picks a random strategy each time --}}
<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" /> {{-- picks a random strategy each time --}}
<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" />
use Mokhosh\Muddle\Facades\Muddle;
use Mokhosh\Muddle\Strategies\Text;
use Mokhosh\Muddle\Strategies\Link;

// default strategy
Muddle::text('test@example.com');
Muddle::link('test@example.com');

// specific strategy
Muddle::strategy(text: new Text\Encrypt)->text('test@example.com')
Muddle::strategy(link: new Link\Encrypt)->link('test@example.com');

In plain 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');

Automatic Title Obfuscation

When using the link method or component, if the email and title attributes are identical (for example, <x-muddle-link email="test@example.com" title="test@example.com" />), the title will be automatically obfuscated using the text strategy. This prevents the email from being exposed in plain text. Please note that this automatic behavior only applies for the default strategy. If you are using a specific strategy you will need to handle this scenario manually.

Configuration

You 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,
    ],

];

Testing

composer test

Todo

  • Add Dusk tests
  • Make loading components dynamic

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

648,266,899 9,701
laravel/framework

The Laravel Framework.

604,216,237 34,982
laravel/tinker

Powerful REPL for the Laravel framework.

512,508,631 7,443
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

429,221,767 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
v5.0.0 ^8.2 ^10.0||^11.0||^12.0||^13.0 MIT
v4.0.0 ^8.2 ^10.0||^11.0||^12.0 MIT
v3.1.0 ^8.2 ^11.0||^12.0 MIT
v3.0.0 ^8.2 ^11.0 MIT
v2.0.0 ^8.2 ^11.0 MIT