Download the PHP package diego-ninja/sentinel without Composer
On this page you can find all versions of the php package diego-ninja/sentinel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download diego-ninja/sentinel
More information about diego-ninja/sentinel
Files in diego-ninja/sentinel
Package sentinel
Short Description A content moderation and sentiment analysis library for Laravel 10+
License MIT
Homepage https://github.com/diego-ninja/sentinel
Informations about the package sentinel
Sentinel for Laravel
Introduction
A powerful and flexible content analysis package for Laravel 10+ applications. Analyze and filter offensive content using multiple services, local dictionaries, and advanced detection strategies.
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
- Multiple service providers support:
- Local dictionary-based analysis
- PurgoMalum
- Tisane AI
- Prism LLM (with support for multiple LLMs)
- Azure AI
- Perspective AI
- Advanced detection strategies:
- Exact match with Trie indexing
- Pattern matching with character substitutions
- N-gram analysis for phrase detection
- Variation detection for obfuscated content
- Repeated character detection
- Levenshtein distance matching
- Rich analysis results:
- Sentiment analysis
- Content categorization
- Match position tracking
- Context and confidence scoring
- Multi-language support
- Whitelist functionality
- Configurable dictionaries
- Laravel Facade and helper functions
- Laravel validation rule
- Caching system
- Full Octane compatibility
Planned Features
- Unicode support enhancement
- More service providers
- Machine learning enhancements
📦 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/sentinel.php
. Here you can configure:
- Default language and available languages
- Default profanity service
- Mask character for moderated words
- Character replacements for evasion detection
- Whitelisted words
- Dictionary path
- Service-specific configurations
- Cache settings
- Analysis thresholds
API Keys Configuration
Some services require API keys. Add these to your .env
file:
⚙️ Basic Usage
You can use Sentinel in three ways:
1. Facade
2. Helper Functions
3. Validation Rule
Available Moderation Providers
Local Provider
Uses local dictionaries with multiple detection strategies for offline profanity checking.
Features:
- Multiple detection strategies
- Fast performance
- No API dependencies
- Configurable pattern matching
PurgoMalum
Free web service for basic profanity filtering.
Azure AI Content Safety
Uses Azure's AI content moderation service with advanced content analysis.
Perspective AI
Uses Google's Perspective API for toxicity and content analysis.
Tisane AI
Natural language processing service for content moderation.
Prism LLM Support
Access various Large Language Models through Prism:
Supported models through Prism:
- Anthropic (Claude models)
- OpenAI (GPT models)
- Gemini
- Mistral
- Ollama
- DeepSeek
- Groq
- xAI
Working with Results
All services return a Result object with consistent methods:
Working with Matches
The MatchCollection provides detailed information about each match:
Categories
The package can detect various content categories:
Sentiment Analysis
Results include sentiment analysis when available:
Response Caching
External service responses are automatically cached to improve performance and reduce API calls. By default, all external services will cache their responses for 1 hour.
The local provider is not cached as it's already performant enough.
Configuring Cache
You can configure the cache in your .env
file:
Or in your config/sentinel.php
:
Cache Keys
Cache keys are generated using the following format:
Detection Strategies
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:
- Trie Index Strategy: Fast exact matching using a Trie data structure
- Pattern Strategy: Handles exact matches and character substitutions
- NGram Strategy: Detects offensive phrases by analyzing word combinations
- Variation Strategy: Catches attempts to evade detection through character separation
- Repeated Chars Strategy: Identifies words with intentionally repeated characters
- Levenshtein Strategy: Uses string distance comparison for similar words
Each strategy can operate in either full word or partial matching mode. 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:
- Create a new PHP file in your
resources/dict
directory - Return an array of words to be moderated
- Update your config to include the new language
Whitelist
You can whitelist words to prevent them from being moderated:
Character Substitution
The package detects common character substitutions. Configure these in:
🙏 Credits
This project is developed and maintained by 🥷 Diego Rin in his free time.
Special thanks to:
- Laravel Framework for providing the most exciting and well-crafted PHP framework.
- Snipe for developing the initial code that serves Sentinel as starting point.
- All the contributors and testers who have helped to improve this project through their contributions.
If you find this project useful, please consider giving it a ⭐ on GitHub!
All versions of sentinel with dependencies
ext-intl Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7
illuminate/contracts Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/support Version ^10.0|^11.0|^12.0
symfony/string Version ^7.2
google/cloud-language Version ^0.34.1
aws/aws-sdk-php Version ^3.334
echolabsdev/prism Version ^0.37.0
lorisleiva/laravel-actions Version ^2.8