Download the PHP package aghfatehi/laravel-smartsearch without Composer

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

PHP Version Laravel Version Tests Packagist Downloads FsoftDev Author

Laravel SmartSearch

Laravel search package — the most versatile full text search for Laravel with OpenSearch, Elasticsearch, Scout, and database search.
Zero-config, production-safe, queue-driven search indexing with AI-powered semantic & vector search.
A powerful Eloquent search engine for your models.


What is Laravel SmartSearch?

Laravel SmartSearch is a powerful, production-ready Laravel search package that provides a unified search API across OpenSearch, Elasticsearch, Laravel Scout, and database full-text search — a true Laravel Scout alternative with more flexibility. Built by Fatehi AL-AGHBARI, it solves the common pain points teams face when adding search to Laravel applications — complex setup, vendor lock-in, and brittle fallback logic.

Whether you need OpenSearch for Laravel, Elasticsearch for Laravel, a Laravel Scout alternative, or database search for Laravel, SmartSearch gives you one clean Laravel search API that works everywhere. The Eloquent search layer integrates directly with your models for zero-friction indexing.


Why Laravel SmartSearch?

Integrating search for Laravel applications often means:

SmartSearch fixes all of this:

Problem Traditional Approach SmartSearch
Setup complexity Hours of config 1-minute setup
Vendor lock-in Tied to one engine Switch drivers anytime
No fallback 503 errors Auto database fallback
Arabic search Custom hacks Built-in normalizer
Indexing overhead Manual sync Auto queue-driven

Features


What Sets SmartSearch Apart

These features are not available in Elasticsearch or Laravel Scout alone. They are the unique value SmartSearch brings:

Feature Elasticsearch Native OpenSearch Native Laravel Scout Native SmartSearch
Single API across engines No No No — Scout providers only Yes — database, OpenSearch, Elasticsearch, and Scout through one API
Standalone DB driver No No Requires Scout ecosystem Yes — works standalone, no extra packages
Queue auto-indexing No — you build it No — you build it Opt-in (SCOUT_QUEUE=true) Yes — enabled by default, zero config
Automatic fallback No — downtime = 503 No — downtime = 503 No — only pagination count fallback Yes — configurable fallback driver
Arabic normalization Server-side only Server-side only No Yes — PHP-level across all drivers
OpenSearch support No N/A (is OpenSearch) Requires community driver Yes — built-in driver, no extra config
Elasticsearch support N/A (is Elasticsearch) No Requires community driver Yes — built-in driver

SmartSearch is not "yet another wrapper." It is an open-source abstraction layer that:


Driver Architecture

SmartSearch decouples your application from the search engine. The architecture has three layers — your code, the manager, and the drivers:

Layer 1 — Your Code (unified API, never changes)

Layer 2 — SearchManager (routes to the active driver)

Setting Value
SMARTSEARCH_DRIVER Pick one: database, opensearch, elasticsearch, scout
SMARTSEARCH_FALLBACK Optional fallback if primary driver fails

Layer 3 — Drivers (execution engines)

Driver Type Mechanism Cost Setup Effort
DatabaseDriver Standalone LIKE / ILIKE auto-detect Free None — works immediately
OpenSearchDriver Standalone HTTP API via opensearch-php Free Medium — Docker self-hosted
ElasticsearchDriver Standalone HTTP API via elasticsearch-php Cloud / Self-hosted Medium — Cloud ID or hosts
ScoutDriver Bridge Delegates to Scout providers Per provider Low — Scout + API keys

ScoutDriver providers:

Provider Type Environment
Algolia Paid cloud SaaS, zero server management
MeiliSearch Free open-source / Paid cloud Self-hosted or managed cloud
Typesense Free open-source / Paid cloud Self-hosted or managed cloud

Installation

Core package

This installs the core package with the database driver only — no extra dependencies, no conflicts.

Optional driver packages

The database driver works immediately. For other search engines, install the corresponding package:

Engine Command Required for
Elasticsearch composer require elasticsearch/elasticsearch SMARTSEARCH_DRIVER=elasticsearch
OpenSearch composer require opensearch-project/opensearch-php SMARTSEARCH_DRIVER=opensearch
Scout (Algolia / MeiliSearch / Typesense) composer require laravel/scout SMARTSEARCH_DRIVER=scout

The package auto-detects which drivers are installed — missing packages just mean that driver throws a clear error message if used.

Publish config (optional)


Quick Setup

1. Add the trait to your model

2. (Optional) Configure your driver

The default driver is database — works immediately with your existing database. To switch to Elasticsearch:

That's it.

Elasticsearch Setup

To use the Elasticsearch for Laravel driver, set the driver in your .env:

Connecting to Elasticsearch

Local / self-hosted:

With Basic Auth:

With API Key (takes precedence over Basic Auth):

Where to get an API key: https://cloud.elastic.co > Your deployment > Stack Management > Security > API Keys > Create API key

Elastic Cloud:

No port or host needed — Cloud ID resolves endpoints automatically.

Where to get Cloud ID: https://cloud.elastic.co > Your deployment > Copy Cloud ID (or Help icon > Connection Details)

Additional Options

Note: The Elasticsearch driver requires a separate install: composer require elasticsearch/elasticsearch. The package detects its presence automatically.


OpenSearch Setup

To use the OpenSearch for Laravel driver, first install the client:

Then set the driver in your .env:

Connecting to OpenSearch

OpenSearch uses the same HTTP API as Elasticsearch. The driver requires opensearch-project/opensearch-php but the setup is almost identical:

Local / self-hosted:

With API Key:

Docker (OpenSearch official image):

Note: OpenSearch is the open-source fork of Elasticsearch — fully compatible API, Apache 2.0 license, no Elastic Cloud dependency. Perfect for self-hosted production search without licensing costs.

Additional Options


Semantic Search (AI-Powered Embeddings & Vector Search)

AI-powered semantic search — a game-changer for the search world.
SmartSearch understands meaning, not just keywords. Powered by free, local Ollama — no subscriptions, no third-party APIs.
Perfect for SEO, user experience, and Arabic & multilingual applications.

SmartSearch supports semantic search using vector embeddings — it understands meaning, not just keywords. This is powered by Ollama (free, local, no API keys).

How it works

Setting Default Description
SMARTSEARCH_EMBEDDINGS_ENABLED false Set to true to enable semantic search
SMARTSEARCH_EMBEDDINGS_PROVIDER ollama Embedding provider (only ollama currently)
SMARTSEARCH_EMBEDDINGS_MODEL nomic-embed-text Model — see ollama embeddings
SMARTSEARCH_EMBEDDINGS_HOST http://localhost:11434 Ollama server URL (Docker: http://ollama:11434)
SMARTSEARCH_EMBEDDINGS_DIMENSIONS auto Vector dimensions (768 for nomic-embed-text)
SMARTSEARCH_EMBEDDINGS_TIMEOUT 30 Request timeout in seconds

1. Install and run Ollama

Docker:

2. Add embedding column to your model's table

3. Configure which fields to embed (optional)

Override searchableEmbeddings() on your model — defaults to the same fields as $smartSearchable:

4. Enable auto-indexing

Set SMARTSEARCH_EMBEDDINGS_ENABLED=true in your .env. The package will generate embeddings for your models automatically on save (via queue jobs).

5. Search semantically

The similarTo() method accepts an optional weight parameter that controls the balance between full-text and semantic results:

Driver compatibility

Driver Vector Search Mechanism
database Yes Cosine similarity in PHP (TEXT column)
opensearch Yes k-NN query on dense_vector field
elasticsearch Yes knn query on dense_vector field
scout No Depends on Scout provider

Zero-cost semantic search: With database driver + Ollama locally, you get AI-powered search for $0 — no API fees, no external services.


Scout Driver

To use the Scout driver, you first install and configure Laravel Scout normally — it has its own .env variables and config/scout.php settings independent of SmartSearch:

Since Scout manages its own model events, use Scout's own Searchable trait on your model (not SmartSearch's):

SmartSearch's ScoutDriver will call Scout's API through your model. Auto-indexing is handled by Scout internally.

Service Signup Get API Keys
Algolia https://www.algolia.com/users/sign_up Dashboard > API Keys
MeiliSearch Cloud https://cloud.meilisearch.com Project Settings > API Keys
Typesense Cloud https://cloud.typesense.org Dashboard > API Keys

Scout is optional (require-dev). Run composer require laravel/scout and publish its config to use it.


Environment Variables

Variable Default Description
SMARTSEARCH_DRIVER database Primary search driver: database, elasticsearch, or scout
SMARTSEARCH_FALLBACK database Fallback driver when primary is unavailable
SMARTSEARCH_QUEUE true Enable/disable queue-driven indexing
SMARTSEARCH_CONNECTION default Queue connection for index/delete jobs
SMARTSEARCH_INDEX_PREFIX `` Prefix for all search index names
ELASTICSEARCH_HOSTS localhost:9200 Comma-separated Elasticsearch hosts
ELASTICSEARCH_ANALYZER standard Elasticsearch text analyzer (e.g. arabic, english)

Usage

Basic search

Search with filters

Paginated search

Eloquent-style shortcut

Helper function


Auto Indexing

SmartSearch hooks into Eloquent events to keep your search index in sync automatically:

Event Action
created Queue IndexDocument job
updated Queue IndexDocument job
deleted Queue DeleteDocument job

All operations are queue-based (non-blocking) and configurable.


Safe Database Fallback

When your primary search engine (Elasticsearch / Scout) is unavailable:

The database driver auto-detects your database engine:

Database LIKE Operator Case-Insensitive
MySQL LIKE Depends on collation
PostgreSQL ILIKE Always
SQLite LIKE ASCII
SQL Server LIKE Depends on collation

Arabic & Multilingual Search

Full Arabic search for Laravel and multilingual search support out of the box:

Configurable Elasticsearch analyzer for any language:


Driver System

Driver When to use
DatabaseDriver (default) Works out of the box — no extra packages needed
ElasticsearchDriver High-performance, dedicated search infrastructure
ScoutDriver Already using Laravel Scout (Algolia, MeiliSearch, Typesense)

Configuration


Architecture

Built on clean architecture principles:


Use Cases


Requirements


Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Commit your changes (git commit -m 'Add my feature')
  4. Push (git push origin feature/my-feature)
  5. Open a Pull Request

Support

If this Laravel search package helps you:


License

MIT License. Free for personal and commercial use.


All versions of laravel-smartsearch with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
illuminate/support Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^9.0|^10.0|^11.0|^12.0|^13.0
illuminate/queue Version ^9.0|^10.0|^11.0|^12.0|^13.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 aghfatehi/laravel-smartsearch contains the following files

Loading the files please wait ...