Download the PHP package gowelle/google-moderator without Composer
On this page you can find all versions of the php package gowelle/google-moderator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gowelle/google-moderator
More information about gowelle/google-moderator
Files in gowelle/google-moderator
Package google-moderator
Short Description Laravel package for text and image moderation using Google AI APIs with opt-in blocklists, multi-language support, and internal engine switching.
License MIT
Homepage https://github.com/gowelle/google-moderator
Informations about the package google-moderator
Google Moderator
A Laravel package for text and image moderation using Google AI APIs, with opt-in blocklists, multi-language support, and internal engine switching.
Table of Contents
- Features
- Requirements
- Installation
- Configuration
- Quick Start
- Validation Rules
- ModerationResult API
- Blocklists
- Engine Comparison
- Thresholds
- Events
- Testing
- Changelog
Features
- ๐ค Text Moderation - Analyze text for toxic, harmful, or inappropriate content
- ๐ผ๏ธ Image Moderation - Detect adult, violent, or racy content in images
- ๐ Multi-Language Support - Swahili-first, with support for any language via custom blocklists
- ๐ Custom Blocklists - File or database-backed blocklists with regex support
- ๐ Engine Switching - Switch between Natural Language API, Vision API, or Gemini
- โก Caching - Built-in caching for blocklist terms
- ๐งช Testable - Fully testable with mocked Google clients
Requirements
- PHP 8.3+
- Laravel 11.x, 12.x, or 13.x
- Google Cloud account with enabled APIs
Installation
Publish the configuration:
Publish the migrations:
Configuration
Authentication
The package supports multiple authentication methods:
Engine Selection
Quick Start
Text Moderation
Image Moderation
Validation Rules
The package provides custom Laravel validation rules for easy integration into your requests and validators.
ModeratedText
Validates that a string is safe according to your configured text engines and blocklists.
ModeratedImage
Validates pictures (uploads, paths, or URLs) against image moderation engines.
ModerationResult API
Blocklists
๐ก Bonus Feature: Google APIs don't provide customizable term blocking. This package includes a complete blocklist system so you can catch domain-specific terms, slang, or phrases that the AI might miss.
Why Blocklists?
- Domain-specific terms - Block product names, competitor mentions, or industry jargon
- Regional slang - Catch offensive terms in local dialects (especially useful for Swahili and other languages)
- Zero-tolerance words - Instantly flag specific terms regardless of AI confidence
- Runs after AI analysis - Combines AI intelligence with your custom rules
Enabling Blocklists
File-Based Blocklists
Create JSON files in storage/blocklists/:
Publish sample files:
Database Blocklists
Store terms in the database for easy management via admin panels.
[!NOTE] Architecture Note: This package uses
DB::table('blocklist_terms')directly for performance and does not include an Eloquent model. You can interact with the table using theDBfacade or the provided Blocklist repository methods.
Ensure you have run the migrations:
Table schema structure:
Import/export via Artisan:
Pattern Matching
Blocklist terms support three matching modes:
| Pattern | Example | Matches |
|---|---|---|
| Exact | badword |
"This is badword here" โ "badwordy" โ |
| Wildcard | *offensive* |
"very offensive content" โ |
| Regex | /\b(bad\|terrible)\b/i |
"This is bad" โ |
Engine Comparison
| Feature | Natural Language | Vision | Gemini |
|---|---|---|---|
| Text Moderation | โ | โ | โ |
| Image Moderation | โ | โ | โ |
| Toxicity Detection | โ (16 categories) | โ | โ |
| SafeSearch | โ | โ | โ |
| Multi-language | โ | N/A | โ |
| Cost | Per request | Per image | Per request |
| Default | โ Text | โ Image | โ Optional |
Thresholds
Configure sensitivity per category:
Events
The package dispatches a ContentFlagged event whenever content is flagged as unsafe:
ContentFlagged Event Properties
Disabling Events
Testing
Mocking in Tests
Changelog
Please see CHANGELOG for recent changes.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover a security vulnerability, please send an email to [email protected].
Credits
- Gowelle
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of google-moderator with dependencies
spatie/laravel-package-tools Version ^1.93
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
google/cloud-language Version ^1.1
google/cloud-vision Version ^2.1