PHPackages                             b7s/neuraphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. b7s/neuraphp

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

b7s/neuraphp
============

Local text embeddings via PHP FFI, powered by embedding.cpp. No Python, no API calls, no external services at runtime.

v1.0.38(1mo ago)13345↓84.6%MITPHPPHP ^8.3

Since May 26Pushed 1mo agoCompare

[ Source](https://github.com/b7s/neuraphp)[ Packagist](https://packagist.org/packages/b7s/neuraphp)[ RSS](/packages/b7s-neuraphp/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (6)Versions (14)Used By (0)

 [![NeuraPHP](docs/logo.png)](docs/logo.png)NeuraPHP
========

[](#neuraphp)

NeuraPHP brings local AI embeddings to PHP—no APIs, no subscriptions, no external services. Run fast, private, personalized text embeddings directly on your machine, saving money while keeping full control of your data. Simple to install, effortless to use, and built for real‑world PHP apps.

[![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://php.net)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)

Features
--------

[](#features)

- **Local embeddings** — No API calls, no network latency, no data leaving your server
- **PHP FFI** — Direct memory access to a **C library**, no separate process
- **Fluent API** — `Neuraphp::make()->model(ModelReference::fromEnum(Model::AllMiniLML12V2))->embed('text')`
- **Multiple models** — AllMiniLM-L6-v2, AllMiniLM-L12-v2, Paraphrase, BGE, E5, multilingual; or any BERT-compatible HuggingFace model
- **Quantization** — F32, F16, Q4\_0, Q4\_1 for speed/quality tradeoffs
- **Vector math** — Cosine similarity, dot product, Euclidean distance, L2 normalization
- **CLI tools** — `neuraphp install` for auto-setup, `neuraphp doctor` for diagnostics, `neuraphp info` for configuration
- **Laravel integration** — Optional service provider and facade
- **Framework-agnostic** — Works with any PHP 8.3+ project

**Docs:** [Manual Installation](docs/advanced-guide.md#manual-installation) · [Quick Start](docs/advanced-guide.md#quick-start) · [API Reference](docs/advanced-guide.md#api-reference) · [Supported Models](docs/advanced-guide.md#supported-models) · [Configuration](docs/advanced-guide.md#configuration) · [Laravel Integration](docs/advanced-guide.md#laravel-integration) · [CLI Reference](docs/advanced-guide.md#cli-commands-reference)

### Add to your project:

[](#add-to-your-project)

```
composer require b7s/neuraphp
```

Quick Start
-----------

[](#quick-start)

```
use B7s\Neuraphp\Neuraphp;
use B7s\Neuraphp\ModelReference;
use B7s\Neuraphp\Enums\Model;

// Embed text (uses default model: AllMiniLML6V2)
$result = Neuraphp::make()->embed('Hello world');
echo $result->dimension();  // 384

// Use a specific model
$result = Neuraphp::make()
    ->model(Model::BgeSmallENV15)
    ->embed('Hello world'); // float[]

// Compare two texts
$similarity = Neuraphp::make()
    ->cosineSimilarity(
       'The cat sat on the mat',
       'A feline rested on the rug'
    ); // 0.87
```

> For more examples, custom models, batch embedding, and the full API, see the [Advanced Guide](docs/advanced-guide.md#quick-start)

⚠️ Prerequisites: embedding.cpp Library &amp; Model
---------------------------------------------------

[](#️-prerequisites-embeddingcpp-library--model)

> **Neuraphp requires `libbert_shared.so` (compiled from [embedding.cpp](https://github.com/b7s/embedding.cpp)) and a GGUF model file to function.**

**Minimum versions required to compile the library:**

ToolMin VersionInstallGit2.0+[git-scm.com](https://git-scm.com)CMake3.18+[cmake.org](https://cmake.org/install/)GNU Make3.81+`sudo apt install build-essential` / `xcode-select --install`C++ compiler (g++/clang++)GCC 10+ / Clang 10+ (C++20)`sudo apt install g++` / `xcode-select --install`Rust (cargo)1.75+[rustup.rs](https://www.rust-lang.org/tools/install)Git LFS2.0+`sudo apt install git-lfs` / `brew install git-lfs`Python3.8+(model conversion only)There are two ways to set these up:

---

### Option A: Automatic Installation (Recommended)

[](#option-a-automatic-installation-recommended)

Run the installation command - it clones, compiles, and downloads everything for you:

```
./vendor/bin/neuraphp install
```

> You need to run this command just once for each model you want to use. If you don't change the model, you don't need to re-run it.

This will:

1. **Check prerequisites** (git, cmake, make, C++ compiler, Rust, git-lfs)
2. **Clone embedding.cpp** into a temp directory and compile `libbert_shared.so`
3. **Download the default model** (all-MiniLM-L6-v2) from HuggingFace
4. **Convert the model** to GGUF format (requires Python 3.8+, torch, transformers)
5. **Copy only final artifacts** to `bin/neuraphp-data/` in your project root
    - **Clean up** temp files and create `bin/neuraphp-data/.gitignore` so artifacts are never committed

**Options:**

```
# Install a specific model (short name or full HuggingFace ID)
./vendor/bin/neuraphp install --model=bge-small-en-v1.5 --quantization=f16

# Install a custom BERT-compatible model
./vendor/bin/neuraphp install --model=custom-org/my-bert-model

# Skip library compilation (if already installed)
./vendor/bin/neuraphp install --skip-library

# Skip model download (if already downloaded)
./vendor/bin/neuraphp install --skip-model

# Force re-download/re-compile
./vendor/bin/neuraphp install --force

# Keep model source files after conversion
./vendor/bin/neuraphp install --keep-source

# Use a specific Python for model conversion
./vendor/bin/neuraphp install --python-path=~/myenv/bin/python3

# Check if Neuraphp is properly configured
./vendor/bin/neuraphp doctor

# Show model and configuration info
./vendor/bin/neuraphp info

# With options
./vendor/bin/neuraphp doctor --library-path=/custom/libbert_shared.so
./vendor/bin/neuraphp info --model=all-MiniLM-L6-v2 --quantization=q4_0
```

Testing
-------

[](#testing)

```
# Run all tests
composer test

# Run with coverage
composer test:coverage

# Code style
composer pint

# Static analysis
composer stan

# Quality gate
composer catraca

# Run all checks
composer check
```

License
-------

[](#license)

MIT

---

Logo by: [Neuro icons created by Uniconlabs - Flaticon](https://www.flaticon.com/free-icons/neuro "neuro icons")

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

13

Last Release

57d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/288a61a41a1bfb6d403f2b322e19f3919ac32a316423ca339a8c4b52c72ccbf3?d=identicon)[bruno.souza](/maintainers/bruno.souza)

---

Top Contributors

[![b7s](https://avatars.githubusercontent.com/u/3808846?v=4)](https://github.com/b7s "b7s (49 commits)")

---

Tags

aiembeddedembeddingslaravellocalphpvectornlpsimilarityembeddingffisemantic-searchBertgguf

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/b7s-neuraphp/health.svg)

```
[![Health](https://phpackages.com/badges/b7s-neuraphp/health.svg)](https://phpackages.com/packages/b7s-neuraphp)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k57](/packages/friendsoftypo3-content-blocks)[phel-lang/phel-lang

Phel is a functional programming language that compiles to PHP

5186.0k19](/packages/phel-lang-phel-lang)[dagger/dagger

Dagger PHP SDK

261.1k](/packages/dagger-dagger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
