Download the PHP package eslam-dev/laravel-searchable without Composer
On this page you can find all versions of the php package eslam-dev/laravel-searchable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eslam-dev/laravel-searchable
More information about eslam-dev/laravel-searchable
Files in eslam-dev/laravel-searchable
Package laravel-searchable
Short Description Laravel Searchable — dedicated searchable columns for Eloquent with cleaning, FULLTEXT search, and rebuild tooling
License MIT
Informations about the package laravel-searchable
Laravel Searchable
A Laravel package for dedicated searchable text columns on Eloquent models: automatic fill on save, text cleaning, and MySQL FULLTEXT search.
Features
✅ Migration Macros - Simple searchableColumn() macro for creating LONGTEXT columns with FULLTEXT indexes
✅ Automatic Population - Searchable columns are automatically updated on model save
✅ Text Cleaning - Comprehensive text normalization (HTML stripping, Arabic normalization, diacritic removal)
✅ FULLTEXT Search - Native MySQL FULLTEXT search with natural language mode
✅ Multiple Columns - Support for multiple searchable columns per model
✅ Relationship Support - Extract text from relationships using dot notation
✅ Translatable Fields - Automatic extraction from JSON/translatable fields
✅ Queue Support - Rebuild searchable columns via queue for large datasets
✅ Highly Configurable - Customize cleaning rules, separators, and extraction methods
Requirements
- PHP 8.2+
- Laravel 12.0+
- MySQL 5.6+ or MariaDB 10.0+
Installation
Install via Composer:
Publish the configuration file:
Quick Start
1. Add Searchable Columns to Migration
2. Add Trait to Model
3. Search Your Data
Advanced Usage
Relationship Fields
Extract text from related models:
Translatable Fields
For models using Spatie's Translatable or JSON fields:
Options:
'all'- Combines all translations: "Phone هاتف"'default'- Uses only the default localefalse- Treats as regular string
Custom Cleaning Rules
Override cleaning rules per model:
LIKE Fallback
For cases where FULLTEXT isn't suitable:
Artisan Commands
Rebuild Searchable Columns
Rebuild searchable columns for existing records:
Configuration
The configuration file config/laravel-searchable.php provides extensive customization options:
Text Cleaning Pipeline
The package applies a comprehensive cleaning pipeline:
- Strip HTML - Removes all HTML tags
- Decode Entities - Converts HTML entities (
&→&) - Normalize Arabic - Standardizes Arabic character variants
- Remove Diacritics - Strips Arabic tashkeel marks
- Convert to Lowercase - Standardizes case for better matching
- Remove Symbols - Strips punctuation and special characters
- Collapse Whitespace - Normalizes spacing
Performance Optimization
MySQL Configuration
For better Arabic search, configure MySQL:
Then rebuild the FULLTEXT index:
Queue Processing
For large datasets, use queue processing:
Configure chunk size in config/laravel-searchable.php:
Eager Loading
The package automatically eager loads relationships used in searchable columns to prevent N+1 queries.
Testing
The package includes comprehensive unit and feature tests:
Test Requirements
Tests require a MySQL database. Configure in phpunit.xml:
Examples
E-commerce Product Search
Multi-language Content
Selective Searchable Columns
Troubleshooting
FULLTEXT Search Not Working
- Ensure you're using MySQL 5.6+ or MariaDB 10.0+
-
Check that FULLTEXT indexes are created:
- Verify minimum word length matches your content:
Arabic Search Issues
- Set
ft_min_word_length = 3in MySQL configuration - Rebuild FULLTEXT indexes:
OPTIMIZE TABLE products; - Verify Arabic normalization is enabled in config
Performance Issues
- Use queue processing for bulk rebuilds
- Adjust chunk size in configuration
- Add database indexes on frequently filtered columns
- Consider using Laravel Scout for more advanced search needs
Security
If you discover any security-related issues, please open a private security advisory on the repository instead of using the public issue tracker.
License
The MIT License (MIT). Please see License File for more information.
Credits
- eslam-dev
- All Contributors
Support
- 🐛 Issues: GitHub Issues
- 📖 Documentation: Full Documentation
All versions of laravel-searchable with dependencies
illuminate/support Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0