Download the PHP package openplain/laravel-lightsearch without Composer

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

Laravel LightSearch

Latest Version on Packagist Total Downloads

Fast, database-backed search for Laravel Scout. No external services, no monthly fees, no infrastructure complexity.

Why This Package?

We created LightSearch because most Laravel applications don't need the complexity of external search services like Algolia or Meilisearch. For small to medium datasets, your existing database is perfectly capable of delivering fast, relevant search results.

Our Goal: Make search simple enough for MVPs, powerful enough for production, and cost-effective for bootstrapped projects.

Real-world performance: 2.95ms average search time on 26,000+ records (view benchmark)

Built on Proven Technology

Rather than reinventing the wheel, LightSearch leverages:

Features

When to Use LightSearch

Perfect for:

Not Ideal for:

Requirements

Installation

Install the package via Composer:

Publish and run migrations:

Optionally publish the configuration file:

Quick Start

1. Configure Scout Driver

Set LightSearch as your Scout driver in .env:

2. Make Your Model Searchable

Add the Searchable trait and define searchable fields:

3. Import Existing Data

Import your existing records into the search index:

For large datasets, use chunking:

4. Start Searching

Use Scout's familiar API to search your models:

Configuration

LightSearch is configured via config/lightsearch.php. All settings are optional with sensible defaults.

Field Weights

Boost relevance of specific fields by giving them higher weights. Fields with higher weights appear multiple times in the index, making matches more significant.

How it works: A post with "Laravel" in the title gets 3 index entries for "Laravel", while the same word in content gets only 1. This makes title matches score higher in results.

Stopwords

Common words to exclude from the search index. This reduces index size and improves performance.

Set to [] to disable stopword filtering.

Minimum Token Length

Minimum character length for a token to be indexed:

Note: Setting this too high (e.g., 4) prevents searching for short terms like "API" or "PHP".

Database Connection

Override the default database connection:

Useful if your search index should live on a different database than your application data.

How It Works

LightSearch uses an inverted index pattern (like Meilisearch, Algolia, and Typesense) implemented in your database:

  1. Indexing: Text is tokenized, normalized, and stored with field weights
  2. Search: Queries use prefix matching (or fuzzy matching on PostgreSQL)
  3. Ranking: Results ordered by occurrence count - more matches rank higher

Field weighting example: with title weight 3 and content weight 1, a match in the title counts 3Γ— more than content.

Advanced Features

Fuzzy Search (PostgreSQL)

PostgreSQL users get automatic typo-tolerant search when the pg_trgm extension is enabled. It handles typos, missing accents, and character substitutions.

Enable pg_trgm (one-time setup):

That's it! Fuzzy search is now automatic:

Adjust threshold (optional):

See FUZZY_SEARCH_RESULTS.md for benchmarks.

Performance

Benchmarked with 26,191 addresses featuring special characters (ΓΈ, Γ‘, Γ°):

Full benchmark report β†’

Comparison

Solution Setup Speed Cost Typo Tolerance
LightSearch 5 min ~3ms $0 Yes (PostgreSQL)
Meilisearch 30 min ~1-5ms $0-$$ Yes
Algolia 15 min ~1-3ms $$$ Yes
Typesense 30 min ~1-5ms $0-$ Yes

Limitations

Be aware of these limitations when choosing LightSearch:

Maintenance

Models are automatically indexed on create/update/delete.

Testing

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Security

If you discover a security vulnerability, please email [email protected]. All security vulnerabilities will be promptly addressed.

Please do not open public issues for security vulnerabilities.

License

The MIT License (MIT). Please see License File for more information.


Built with ❀️ by Openplain


All versions of laravel-lightsearch with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/scout Version ^9.0 || ^10.0 || ^11.0
illuminate/support Version ^10.0 || ^11.0 || ^12.0
illuminate/database Version ^10.0 || ^11.0 || ^12.0
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 openplain/laravel-lightsearch contains the following files

Loading the files please wait ...