Download the PHP package opensolr/laravel-opensolr-search without Composer

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

Laravel Opensolr Search

A small, complete Laravel application that puts a Vue search interface in front of an Opensolr index. Search is hybrid: keyword relevance (BM25) and semantic similarity (kNN over server-side embeddings) fused per document, so "sleepy pets" finds the article about cats napping. One page searches an Eloquent model through Laravel Scout; the other searches the whole index and can write a grounded answer from the top hits.

Everything talks to Opensolr through one package, opensolr/laravel-scout-opensolr, documented at opensolr.com/laravel-search. There is no Solr client to configure, no schema to design and no embedding model to run.

What is inside

Page Route What it demonstrates
Index search / embed_and_search over the whole index: hybrid ranking, highlighting, spelling suggestions, facet counts, a "fresh results first" toggle and an Ask AI button that grounds an answer on the top hits.
Eloquent search /eloquent Stock Scout on an Article model: Article::search($q)->where('category', $c)->paginate(). Twenty seeded articles in five categories.

The JSON endpoints behind the pages live in routes/api.php and are rate limited per client address (60 searches and 10 AI answers per minute).

Requirements

Quick start

The .env.example file points at Opensolr's public demo account, so the application runs before you have an account of your own.

create-project copies .env.example to .env, generates the application key, creates the SQLite database and seeds the articles. Working from a clone instead:

then continue from opensolr:create-index above.

Open http://localhost:8000. The index search works immediately: OPENSOLR_INDEX points at the demo account's news index, which is loaded and read-only. opensolr:create-index creates a vector index of your own on the account and writes its name to OPENSOLR_SCOUT_INDEX; that is where scout:import sends the twenty seeded articles. They become searchable on the Eloquent page about a minute later, once the Data Ingestion API has embedded them server-side. Progress is visible in the Control Panel under Data Ingestion.

composer setup runs the same steps in one go, except the two opensolr:create-index and scout:import lines.

For development with hot reloading, run npm run dev next to php artisan serve.

The demo account

[email protected] is a public, shared, throwaway account. Know what you are working with:

When you want an index that is private, yours and still there next week, register (the free plan is free forever, no card), create a vector-enabled index in the Control Panel, and change three lines in .env:

With OPENSOLR_SCOUT_INDEX empty, both pages use the same index, which is the normal setup: one index serves every searchable model and the whole-index search alike. Nothing else in the code changes.

How it works

The Eloquent side

app/Models/Article.php uses the Searchable trait and returns the fields to index from toSearchableArray(). The driver stores title and description as the document's title and description, joins every value into the text that gets embedded, and keeps each scalar key as a filterable meta_* field. That last part is what makes ->where('category', …) work: it becomes a Solr filter on meta_category.

app/Http/Controllers/ArticleSearchController.php is plain Scout. Search, filter, paginate. The driver adds a meta_model scope to every query, so one Opensolr index can serve every searchable model in an application.

Indexing is asynchronous. scout:import and model saves go through Opensolr's Data Ingestion API, which computes embeddings and derived fields on the server; documents become searchable within about a minute.

The index side

app/Search/IndexSearch.php calls OpensolrClient::embedAndSearch(). That single request embeds the query, fuses keyword and semantic scores, highlights, facets, spell-checks and applies the Search Tuning saved for the index in the Control Panel. The service reduces the response to what the page shows and drops the rest: the raw Solr parameters, the query vector and the debug block never reach the browser.

The "fresh results first" toggle sets the fresh_bias tuning knob, which re-orders by recency and hides nothing. It is the same control visitors get on Opensolr's hosted search page.

Ask AI calls OpensolrClient::aiAnswer(): the platform retrieves the top hybrid hits for the question and writes an answer from them. The page shows the answer as plain text next to the results it was written from.

The Vue side

resources/js/composables/useSearch.js is the one piece of shared logic: a request state machine that aborts the previous fetch, ignores responses that arrive out of order and exposes loading, error and result. Both page components use it. It replaces the Vue 2 mixin the first version of this project was built around.

Highlights are the one place a search page usually reaches for innerHTML. This one does not. Solr marks hits with <em> and leaves the surrounding text unescaped, so the server splits every fragment into [text, hit] segments and HighlightText.vue renders them as text nodes, wrapping only the hits in <mark>.

Security notes

Project history

The first version of this repository, from 2019, used Solarium against a Solr endpoint directly, Laravel 6 and Vue 2 with a mixin. It is preserved in the git history under the tag legacy-solarium. This version replaces all of it with the Opensolr platform API, Laravel 13, Vue 3 and Vite.

License

MIT.


All versions of laravel-opensolr-search with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
laravel/framework Version ^13.17
laravel/tinker Version ^3.0
opensolr/laravel-scout-opensolr Version ^0.6.2
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 opensolr/laravel-opensolr-search contains the following files

Loading the files please wait ...