Download the PHP package jamal/universal-search-filter without Composer

On this page you can find all versions of the php package jamal/universal-search-filter. 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 universal-search-filter

Universal Search Filter for Laravel

A drop-in trait and query builder macro that turns a single search box into rich conditions across selected columns, relations, and casts — with optional Scout integration and relevance ranking.

Why?

Most apps need a "one box" search that just works across names, emails, and related records without hand-writing SQL each time. This package gives you a clean universalSearch() scope plus a whereUniversalSearch() macro you can apply to any Eloquent query.

Features

Installation

This publishes config/universal_search.php to tweak defaults.

Quick Start

In your Eloquent model:

Then in a controller:

The scope adds a computed _universal_relevance column, and orders by it (higher is better).

What is weight?

Weight is simply a number that shows how important a column (or relation) is compared to others when calculating the relevance score.

Here is how it works:

For example:

If you search for "alice":

The query then orders by _universal_relevance DESC, so results with matches in high-weighted columns appear first.

So weight = ranking priority. It does not remove columns from search, it just decides which matches push a record higher in the list.

Using the Query Builder Macro

If you are on the Query Builder directly (no model) and want a simple multi-column search:

Scout (Optional)

If you have Laravel Scout and your model uses the Searchable trait, enable the setting in config/universal_search.php:

The scope will route searches via Scout, then hydrate your Eloquent query based on the keys returned. If no results are found, it falls back to the Eloquent driver.

Configuration

config/universal_search.php:

Notes on Relevance

The package builds a simple relevance score with a CASE WHEN column LIKE ? THEN weight sum across tokens and columns. This is portable and works on MySQL, Postgres, and SQLite. For advanced ranking, consider switching to Scout with a dedicated engine (e.g., Meilisearch, Algolia, TNTSearch).

Examples

Search users by "john doe" across users and their posts:

Provide options at call site:

Use only the macro with manual columns:

Testing (stub)

You can write tests by making a few models with the trait and seeding a handful of rows, then asserting counts and order of _universal_relevance.

License

MIT

Tailored Defaults

Out of the box, the config ships with useful defaults:

Override at the model level by defining $universalSearch or globally by publishing the config.

Running Tests

This package uses PHPUnit with Orchestra Testbench.

The test suite provisions an in-memory SQLite database, runs simple migrations, seeds demo data, then verifies:


All versions of universal-search-filter with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version ^10.0|^11.0
illuminate/database Version ^10.0|^11.0
illuminate/pagination Version ^10.0|^11.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 jamal/universal-search-filter contains the following files

Loading the files please wait ...