Download the PHP package devtrope/profanity-filter without Composer

On this page you can find all versions of the php package devtrope/profanity-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package profanity-filter

Profanity Filter

A small, dependency-free PHP library to detect and censor profanity in text.

Features

Requirements

Installation

Usage

Censor a text

Every character of a profane word is replaced by the replacement string (* by default). The rest of the text is returned untouched.

Check a text

Get the details

getMatches() returns one Detection object per profane word found, in the order they appear in the text.

Property Description
original The word exactly as it was written in the text (sh1t)
profanity The entry of the word list that matched (shit)
position Position of the word in the text, starting at 0

This is useful to tell users why a message was refused, to feed a moderation queue, or to apply your own rules (for example, reject a message after a certain number of detections).

Choose a language

Pass a locale to the constructor. The default is en.

Available locales: en, fr, es, de, it, pt.

A MissingBlacklistFileException is thrown if no word list exists for the given locale, and an InvalidBlacklistException if a list is not valid JSON or is not a list of words.

On a multilingual site, create one filter per language and reuse it, rather than mixing every language in one list: a harmless word in one language is sometimes a profanity in another.

Add or remove words

Words must be written in lowercase, as a single word (no spaces). Removing a word is also how you handle a false positive for your own audience.

What gets detected

Text Detected Why
Shit, SHIT yes case-insensitive
sh1t, $hit yes leetspeak
shiiiiit yes stretched letters
s.h.i.t yes punctuation inside the word
shit!, (shit) yes punctuation around the word
class, assume no the profanity is only part of another word
455 no numbers are not converted to letters

Limitations

This library is a word filter, not a moderation system. Keep these limits in mind:

Word lists

Lists are stored in data/blacklist.{locale}.json. A list is a flat JSON array of words:

Rules for the entries:

Contributions for new languages or missing words are welcome: add or edit the file and the matching tests, then open a pull request.

Upgrading from 0.0.x

This version is not backward compatible with the 0.0.x releases. The main differences:

Testing

License

Released under the MIT License.


All versions of profanity-filter with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package devtrope/profanity-filter contains the following files

Loading the files please wait ...