Polyscope - The agent-first dev environment for Laravel

Muddle

Muddle stats

Downloads
32
Stars
5
Open Issues
0
Forks
0

View on GitHub →

Obfuscate emails and strings in PHP and Laravel

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

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

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

Optionally, you can publish the views using

php artisan vendor:publish --tag="muddle-views"

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.

mokhosh photo

Barely anything...

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Mokhosh Muddle Related Articles

Hide and safeguard emails from bots with the Muddle Laravel package image

Hide and safeguard emails from bots with the Muddle Laravel package

Read article
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Tighten logo

Tighten

We help companies turn great ideas into amazing apps, products, and services.

Tighten
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
DreamzTech logo

DreamzTech

Hire 6-10+ Yrs. experienced skilled Laravel Developers from DreamzTech. We ensure NDA protected, 100% quality delivery. Contact Us & Discuss Your Need.

DreamzTech