Download the PHP package diego-ninja/laravel-censor without Composer

On this page you can find all versions of the php package diego-ninja/laravel-censor. 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 laravel-censor

💀 Censor - Profanity and word filtering library for Laravel 10+

Latest Version on Packagist Total Downloads PHP Version License: MIT GitHub last commit Hits-of-Code wakatime

Introduction

A powerful and flexible profanity filtering package for Laravel 10+ applications. Filter offensive content using multiple services or local dictionaries.

This documentation has been generated almost in its entirety using 🦠 Claude 3.5 Sonnet based on source code analysis. Some sections may be incomplete, outdated or may contain documentation for planned or not-released features. For the most accurate information, please refer to the source code or open an issue on the package repository.

❤️ Features

📦 Installation

You can install the package via composer:

After installing, publish the configuration file and dictionaries:

🎛️ Configuration

The package configuration file will be published at config/censor.php. Here you can configure:

API Keys Configuration

Some services require API keys. Add these to your .env file:

⚙️ Basic Usage

You can use Laravel Censor in three ways:

1. Facade

2. Helper Functions

3. Validation Rule

Available Services

Local Censor

Uses local dictionaries for offline profanity checking.

PurgoMalum

Free web service for profanity filtering.

Azure AI Content Safety

Uses Azure's AI content moderation service.

Perspective AI

Uses Google's Perspective API for content analysis.

Tisane AI

Natural language processing service for content moderation.

Working with Results

All services return a Result object with consistent methods:

Response Caching

External service responses are automatically cached to improve performance and reduce API calls. By default, all external services (PurgoMalum, Azure AI, Perspective AI, and Tisane AI) will cache their responses for 1 hour.

The local censor service is not cached as it's already performant enough.

Configuring Cache

You can configure the cache TTL and cache store in your .env file:

Or in your config/censor.php:

The caching system uses Laravel's cache system, so it will respect your cache driver configuration (config/cache.php). You can use any cache driver supported by Laravel (Redis, Memcached, file, etc.).

Cache Keys

Cache keys are generated using the following format:

For example:

This ensures unique caching for:

Detection Mechanism

The local checker uses a multi-strategy approach to detect offensive content accurately. Each piece of text is processed through different detection strategies in sequence:

  1. Pattern Strategy: Handles exact matches and character substitutions (like '@' for 'a', '1' for 'i'). This is the primary detection method and uses precompiled regular expressions for efficiency.

  2. NGram Strategy: Detects offensive phrases by analyzing word combinations. Unlike single-word detection, this strategy can identify offensive content that spans multiple words.

  3. Variation Strategy: Catches attempts to evade detection through character separation (like 'f u c k' or 'f.u.c.k'). This strategy understands various separator patterns while respecting word boundaries.

  4. Repeated Chars Strategy: Identifies words with intentionally repeated characters (like 'fuuuck'). This helps catch common obfuscation techniques.

  5. Levenshtein Strategy: Uses string distance comparison to find words that are similar to offensive terms, helping catch typos and intentional misspellings.

Each strategy can operate in either full word or partial matching mode, with full word mode ensuring that matches are not part of larger words (preventing false positives like 'class' matching 'ass'). Results from all strategies are combined, deduplicated, and scored based on the type and quantity of matches found.

Custom Dictionaries

You can add your own dictionaries or modify existing ones:

  1. Create a new PHP file in your resources/dict directory
  2. Return an array of words to be censored
  3. Update your config to include the new language

Whitelist

You can whitelist words to prevent them from being censored:

Character Substitution

The package detects common character substitutions (e.g., @ for a, 1 for i). Configure these in:

🙏 Credits

This project is developed and maintained by 🥷 Diego Rin in his free time.

Special thanks to:

If you find this project useful, please consider giving it a ⭐ on GitHub!


All versions of laravel-censor with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-intl Version *
guzzlehttp/guzzle Version ^7
illuminate/contracts Version ^10.0|^11.0
illuminate/http Version ^10.0|^11.0
illuminate/support Version ^10.0|^11.0
symfony/string Version ^7.2
google/cloud-language Version ^0.34.1
aws/aws-sdk-php Version ^3.334
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 diego-ninja/laravel-censor contains the following files

Loading the files please wait ....