定制 mokhosh/muddle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mokhosh/muddle

Composer 安装命令:

composer require mokhosh/muddle

包简介

Obfuscate emails and strings in PHP and Laravel

README 文档

README

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.

mokhosh/muddle 适用场景与选型建议

mokhosh/muddle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.07k 次下载、GitHub Stars 达 78, 最近一次更新时间为 2024 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「Mo Khosh」 「muddle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 mokhosh/muddle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mokhosh/muddle 我们能提供哪些服务?
定制开发 / 二次开发

基于 mokhosh/muddle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 13.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 79
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 78
  • Watchers: 1
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-01