承接 askedio/laravel5-profanity-filter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

askedio/laravel5-profanity-filter

最新稳定版本:1.10

Composer 安装命令:

composer require askedio/laravel5-profanity-filter

包简介

A Vendor Package Example

关键字:

README 文档

README

Build Status StyleCI

Laravel Profanity Filter

Filter profanity, or other bad words, out of a string using Laravels localization feature or with any PHP application and some custom coding.

Installation

composer require askedio/laravel5-profanity-filter

Register in config/app.php.

Register the service providers in Laravel 5.4 or lower to enable the package:

Askedio\Laravel5ProfanityFilter\Providers\ProfanityFilterServiceProvider::class,

Configure

php artisan vendor:publish

You can edit the default list of words to filter along with the settings in config/profanity.php.

replaceWith can also be a string of chars to be randomly chosen to replace with, like '&%^@#'.

You can create your own list of words, per language, in resources/lang/[language]/profanity.php.

Usage

$string = app('profanityFilter')->filter('something with a bad word');

The $string will contain the filtered result.

You can also define things inline

$string = app('profanityFilter')->replaceWith('#')->replaceFullWords(false)->filter('something with a bad word'));

You can also use the profanity filter with Laravels Validation feature:

$request->validate([
    'title' => 'required|profanity|unique:posts|max:255',
]);

Options

  • filter($string = string, $details = boolean) pass a string to be filtered.

    • Enable details to have an array of results returned:
      [
        "orig" => "",
        "clean" => "",
        "hasMatch" => boolean,
        "matched" => []
      ]
  • reset() reset replaceWith and replaceFullWords to defaults.

  • replaceWith(string) change the chars used to replace filtered strings.

  • replaceFullWords(boolean) enable to replace full words, disable to replace partial.

Profanity Filter with PHP

You can also use this package without Laravel.

use Askedio\Laravel5ProfanityFilter\ProfanityFilter;

$config = []; // Data from `resources/config/profanity.php`
$badWordsArray = []; // Data from `resources/lang/[lang]/profanity.php`

$profanityFilter =  new ProfanityFilter($config, $badWordsArray);
$string = $profanityFilter->filter('something with a bad word');

Credits

This package is based on banbuilder.

统计信息

  • 总下载量: 346.09k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 53
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 52
  • Watchers: 1
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: AGPL-3.0
  • 更新时间: 2016-11-23