Download the PHP package whitecube/laravel-search-builder without Composer

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

Search Builder for Laravel

A package to build fast, index-friendly search queries for Laravel.

What does it do?

The purpose of this package is to allow you to build multi-condition search queries with scores, and make use of covering indexes to be super fast. This means simply using this package as shown is not everything – you need to have a well designed database, with properly designed indexes for your searches, to get good results. To learn more about this topic, we recommend watching the free PlanetScale MySQL for Developers course.

Installation

How to structure your query

To make your search queries extremely fast, the search builder will pack all of your conditions in a subquery that will aim to hit as many covering indexes as possible, in order to build an aggregated table that only contains ids of the pertinent models (along with a score, more on this later). This aggregated table will then be used to filter down the actual table with an inner join. This means that the processing of your search logic is done entirely on your indexes, and the full table is only accessed at the end, which dramatically speeds everything up.

However, the package can not detect your database structure, so it is your responsibility to create your indexes correctly, and in such a way that your search condition queries will not have to access your main tables' data.

Here's an example of what we're looking to achieve, in raw SQL. Given that we have a products table, and we want to search it by reference and by name, and prioritise the reference over the name:

The search builder instance

You can get a search builder instance just by passing it the model you want to search.

Or, if your model uses the HasSearchBuilder trait, you can easily get a search builder instance this way, which allows you to cleanly chain your condition methods later.

Defining search conditions

Once you have a search builder instance, you can use it to define your search conditions, by passing eloquent builder instances to the search method.

The score is optional and will be automatically computed if missing, using the order in which the conditions are defined, with the highest score on top.

You can easily search on related tables. Remember to only select the column that references the id of the table you're searching.

If you wish to split the search terms on spaces, dashes, dots and underscores, and perform individual queries on each term, you can call the splitTerms method.

Getting the results

After defining your conditions, you can get the collection of results by calling the get method.

Or, if you need to do more work on the query yourself, you can get the query builder instance.

💖 Sponsorships

If you are reliant on this package in your production applications, consider sponsoring us! It is the best way to help us keep doing what we love to do: making great open source software.

Contributing

Feel free to suggest changes, ask for new features or fix bugs yourself. We're sure there are still a lot of improvements that could be made, and we would be very happy to merge useful pull requests.

Thanks!

Unit tests

When adding a new feature or fixing a bug, please add corresponding unit tests. The current set of tests is limited, but every unit test added will improve the quality of the package.

Run the test suite by calling ./vendor/bin/pest.

Made with ❤️ for open source

At Whitecube we use a lot of open source software as part of our daily work. So when we have an opportunity to give something back, we're super excited!

We hope you will enjoy this small contribution from us and would love to Twitter for more updates!


All versions of laravel-search-builder with dependencies

PHP Build Version
Package Version
Requires laravel/framework Version ^9.0|^10.0|^11.0
staudenmeir/laravel-cte Version ^1.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 whitecube/laravel-search-builder contains the following files

Loading the files please wait ....