Download the PHP package provydon/laravel-pgsearch without Composer
On this page you can find all versions of the php package provydon/laravel-pgsearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download provydon/laravel-pgsearch
More information about provydon/laravel-pgsearch
Files in provydon/laravel-pgsearch
Package laravel-pgsearch
Short Description PostgreSQL-friendly search for Eloquent (ILIKE + normalization; optional FTS/trigram later).
License MIT
Informations about the package laravel-pgsearch
๐ Laravel PostgreSQL Search
Smart PostgreSQL search for Laravel with text normalization and relationship support.
โจ Why This Package?
- ๐ฏ Smart matching: Find "Jane Doe" even when stored as "Jane-Doe"
- ๐ฑ Phone numbers: Search "1234567890" matches "(123) 456-7890"
- ๐ Relationships: Search across related models seamlessly
- โก PostgreSQL optimized: Uses ILIKE and REGEXP_REPLACE for performance
- ๐ก๏ธ Safe fallback: Works on non-PostgreSQL databases (no-op)
๐ Quick Start
Install
Use Immediately
That's it! No configuration needed.
๐ Support
If this package helped you, consider supporting its development:
๐ Usage Examples
Basic Search
Relationship Search
Advanced Options
Ordering and Custom Sort
When order_by_best_match is enabled (default), results are ranked by relevance: exact phrase match (100) > normalized match (50) > word token match (10). This prevents generic words (e.g. "office") from returning the wrong row when multiple rows match.
Custom ordering: Chain your orderBy after pgSearch() so relevance is primary and your column is the tiebreaker:
To disable best-match ordering entirely, pass ['order_by_best_match' => false] or set it in config.
Helper Function
For convenience, you can also use the pg_search() helper function:
๐ง Configuration (Optional)
Publish config to customize behavior:
๐ง How It Works
The package performs intelligent PostgreSQL searches:
| Search Type | SQL Example | Matches |
|---|---|---|
| Direct | name ILIKE '%john doe%' |
"John Doe", "JOHN DOE" |
| Normalized | REGEXP_REPLACE(phone, '[^a-zA-Z0-9]', '', 'g') ILIKE '%1234567890%' |
"(123) 456-7890", "123-456-7890" |
Real-World Examples
๐ Requirements
- Laravel: 10.0+, 11.0+, 12.0+, or 13.0+
- PHP: 8.1+
- Database: PostgreSQL (graceful fallback for others)
โก Performance Tips
For frequently searched columns, add expression indexes to speed up normalized searches:
Important: Use the exact same expression as in the search query for optimal performance.
๐งช Testing
๐ License
MIT License - see LICENSE for details.
Made with โค๏ธ for the Laravel community
All versions of laravel-pgsearch with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0