Download the PHP package ismailelbery/laravel-arabic-search without Composer

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

Laravel Arabic Search

Latest Version on Packagist Tests Total Downloads PHP Version

Arabic search that works on MySQL / PostgreSQL / SQLite — no Elasticsearch, no Meilisearch.

Arabic text is written many ways for the same word: with or without diacritics, أ/إ/آ vs bare ا, ة vs ه, ى vs ي, and Persian/Urdu look-alike letters (ک, ی) that are visually identical to Arabic ones but sit at different Unicode codepoints. Naive LIKE misses all of these. This package normalizes both your stored text and the search term through the same pipeline, so مكة matches مكه, مُحَمَّد matches محمد, and کتاب (Persian keheh) matches كتاب (Arabic kaf).

You declare which columns are searchable once on the model; at query time you pass only the search word.


Installation

Requirements: PHP 8.1+, Laravel 10 / 11 / 12, and ext-mbstring. ext-intl is optional — if present it adds an NFKC pass that folds Arabic presentation forms from PDFs; a built-in map covers the common cases when it is absent.


Normalization rules

This table is the contract. Each rule is individually toggleable in config/arabic-search.php.

Rule Transform Example Default
strip_invisibles remove zero-width & bidi controls (U+200B–200F, U+061C, U+FEFF, …) احمد‏احمد on
unicode_compatibility NFKC / presentation forms & ligatures لا on
strip_tashkeel remove harakat & Quranic marks (U+064B–065F, U+0670, U+06D6–06ED, …) مُحَمَّدمحمد on
strip_tatweel remove kashida U+0640 محـــمدمحمد on
normalize_alef أ إ آ ٱ ٲ ٵ → ا إسلاماسلام on
normalize_yeh ى (maqsura), ی (Farsi), ے (Urdu) → ي موسى, موسیموسي on
normalize_taa_marbuta ة → ه مكةمكه on
normalize_heh ہ ۀ ە (Urdu/Persian) → ه ہه on
normalize_kaf ک ڪ (Persian/Urdu) → ك کتابكتاب on
normalize_waw ؤ ۆ ۇ ۈ → و مؤمنمومن on
normalize_hamza ؤ → و, ئ → ي قائمقايم on
strip_standalone_hamza ء → (removed) سماءسما off
normalize_dad_zah ظ → ض (tolerant of a common misspelling) ظلضل off
normalize_digits ٠١٢٣ and ۰۱۲۳ (Persian) → 0123 ٢٠٢٥2025 on
lowercase_latin lowercase mixed Latin HeLLohello on
collapse_whitespace runs of whitespace → single, trim محمدمحمد on

Design decision — recall over precision. Normalization is intentionally lossy: مكة and مكه will match, by design. Precision is recovered by relevance ordering (exact > prefix > contains), not by being conservative here.

Two rules are off by default because they are lossy across genuinely different words, not just spelling variants of one letter — enable them only if you want that tolerance:

Enable in config/arabic-search.php:

Changing it changes the normalizer version — run arabic-search:rebuild afterwards for shadow-column tables.

Debug any term end-to-end:


Setup on a model

  1. Add the trait and list your searchable columns:

  2. Add the shadow columns. Edit the published migration (or write your own using the macro):

  3. Backfill existing rows:

That's it. New/updated rows keep their shadow columns in sync automatically on save.


How it works

You never search the original column. The package maintains a normalized shadow column next to it (titletitle_normalized). On save, an observer normalizes the source into the shadow column; on search, the term is normalized with the same pipeline and matched against the shadow column. Because both sides run identical PHP normalization, they are guaranteed to agree — there is no SQL-vs-app drift.

⚠️ Bulk writes bypass model events. Model::query()->update(), insert(), upsert() and raw SQL do not fire the observer, so the shadow columns go stale. Run arabic-search:rebuild afterwards.


Standalone normalizer (no model needed)


Searching an existing table with no shadow column

Have a legacy users table you can't (or don't want to) alter? Use variant expansion — it matches every orthographic spelling directly against the raw column, no _normalized column and no rebuild needed:

Searching اسلام matches stored اسلام, إسلام, أسلام, آسلام, الإسلام, and diacritized/kashida spellings like إِسْلَام and اســلام — while correctly not matching a different word like اسلم. It works on MySQL, PostgreSQL and SQLite (a PCRE-backed REGEXP function is registered automatically for SQLite).

When to use which:

Shadow column (HasArabicSearch) Variant expansion (whereArabicVariants)
Schema change adds _normalized column none
Backfill arabic-search:rebuild none
Matching LIKE on the normalized column regex on the raw column
Uses an index no in v1 (LIKE infix); fulltext planned no (regex full-scan)
Best for tables you own legacy/read-only tables, small–medium

Configuration highlights

Key Meaning
term_logic and (all tokens must match, default) or or (any)
order_by_relevance exact > prefix > contains ordering (default true)
min_token_length tokens shorter than this are dropped (default 2)
column_suffix shadow-column suffix (default _normalized)
match_mode reserved. v1 always uses like; index-backed fulltext is on the roadmap and not yet wired

Changing any rule changes the normalizer version (ArabicSearch::version()); rerun arabic-search:rebuild so stored data matches.


What this does NOT do (yet)

Naming the limits earns more trust than hiding them:

Use this vs. Meilisearch/Typesense: reach for this when you want correct Arabic matching on the database you already have, with zero extra infrastructure. Reach for a dedicated engine when you need typo-tolerance, faceting, or sub-10ms search over millions of rows.


Testing

The suite leads with an input → expected-output table (NormalizationTest) plus idempotency checks and an integration SearchTest against in-memory SQLite.

License

MIT.


All versions of laravel-arabic-search with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-mbstring Version *
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 ismailelbery/laravel-arabic-search contains the following files

Loading the files please wait ...