PHPackages                             subhashladumor1/larachain - 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. [Framework](/categories/framework)
4. /
5. subhashladumor1/larachain

ActiveLibrary[Framework](/categories/framework)

subhashladumor1/larachain
=========================

LaraChain - LangChain-inspired AI orchestration framework for PHP and Laravel

1.0.1(2mo ago)02MITPHPPHP ^8.0

Since Mar 8Pushed 1mo agoCompare

[ Source](https://github.com/subhashladumor1/larachain)[ Packagist](https://packagist.org/packages/subhashladumor1/larachain)[ RSS](/packages/subhashladumor1-larachain/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (3)Used By (0)

🏗️ LaraChain (Beta Version)
===========================

[](#️-larachain-beta-version)

[![Latest Version on Packagist](https://camo.githubusercontent.com/347035b7f1e932fa1e9a5c9f071ac1f8f0c4cf2b5905d679fe2ebc16eb503ed9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737562686173686c6164756d6f72312f6c617261636861696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/subhashladumor1/larachain)[![GitHub Tests Action Status](https://camo.githubusercontent.com/60afb5f5809ffed2628c4a02d1186a9ae9153b882b3b96fa7ceaac996bc5398e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737562686173686c6164756d6f72312f6c617261636861696e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/subhashladumor1/larachain/actions)

**LaraChain** is a LangChain-inspired AI orchestration framework built specifically for **Laravel 12**. In 2026, building AI apps is no longer just about calling an API—it's about building **Stateful Workflows**, **Agentic Tools**, and **Modern RAG pipelines**. LaraChain provides the primitives to build these with professional-grade elegance and type safety.

---

🗺️ How LaraChain Works
----------------------

[](#️-how-larachain-works)

LaraChain follows a "Runnable" architecture where every component—prompts, models, retrievers, and parsers—can be piped together.

 ```
graph LR
    A[Input Variables] --> B[PromptTemplate]
    B -->|Pipe| C[ChatModel]
    C -->|Pipe| D[OutputParser]
    D --> E[Final PHP Object]

    subgraph "The RAG Loop"
        F[PDF/Web/CSV] --> G[TextSplitter]
        G --> H[EmbeddingModel]
        H --> I[VectorStore]
        I -->|Retrieve| B
    end
```

      Loading ---

🚀 Key Features
--------------

[](#-key-features)

FeatureDescription**LCEL-style Piping**Use the `.pipe()` pattern to chain components like a pro.**Smart Agents**ReAct (Reasoning + Acting) agents that use tools and make decisions.**Advanced RAG**Document loaders, recursive text splitting, and vector retrieval.**Postgres Support**Native `pgvector` integration for production-ready storage.**Memory Drivers**Stateful conversation buffers to maintain context.**Laravel 12 Native**Deeply integrated with the Laravel AI SDK and Service Container.---

📂 Folder Structure
------------------

[](#-folder-structure)

```
larachain/
├── src/
│   ├── Agents/           # ReAct and Agentic logic
│   ├── Chains/           # Pipeline orchestration (Sequential, Router)
│   ├── Contracts/        # Interfaces for all components
│   ├── DocumentLoaders/  # Reading PDF, Web, CSV contents
│   ├── Embeddings/       # Vector generation logic
│   ├── Laravel/          # Service Providers and Facades
│   ├── Memory/           # Conversation state management
│   ├── Messages/         # Message objects (User, Assistant, System)
│   ├── Models/           # AI Model wrappers (ChatModel)
│   ├── Parsers/          # Output formatting (JSON, XML)
│   ├── Prompts/          # Template management
│   ├── Retrieval/        # Document retrieval logic
│   ├── Support/          # Traits and Helpers (HasPipe)
│   ├── TextSplitters/    # Document chunking logic
│   ├── Toolkits/         # Grouped tools (File, Database)
│   ├── Tools/            # Individual tool implementations
│   └── VectorStores/     # Storage drivers (In-Memory, Postgres)

```

---

📖 Functional API Guide
----------------------

[](#-functional-api-guide)

### 1. The Pipe Pattern (Recommended)

[](#1-the-pipe-pattern-recommended)

The hallmark of LaraChain 2026 is the ability to chain components elegantly.

```
use LaraChain\Prompts\PromptTemplate;
use LaraChain\Models\ChatModel;
use LaraChain\Parsers\JsonParser;

$chain = PromptTemplate::make('Extract data from this text: {text} into JSON format.')
    ->pipe(new ChatModel('gpt-4o'))
    ->pipe(new JsonParser());

$output = $chain->invoke(['text' => 'My name is John and I live in London.']);
// Returns: ['name' => 'John', 'location' => 'London']
```

### 2. Intelligent Agents

[](#2-intelligent-agents)

An agent can use specialized tools to complete complex tasks.

```
use LaraChain\Agents\AgentExecutor;
use LaraChain\Toolkits\FileToolkit;

$agent = AgentExecutor::make()
    ->tools((new FileToolkit())->getTools());

$response = $agent->run("Read config.json and summarize it in readme.md");
```

### 3. RAG (Postgres + Recursive Chunking)

[](#3-rag-postgres--recursive-chunking)

Handle large documents with state-of-the-art chunking and production storage.

```
use LaraChain\TextSplitters\RecursiveCharacterTextSplitter;
use LaraChain\VectorStores\PostgresVectorStore;
use LaraChain\Embeddings\EmbeddingModel;

$splitter = new RecursiveCharacterTextSplitter(chunkSize: 1000, chunkOverlap: 200);
$chunks = $splitter->splitText($largePdfContent);

$store = new PostgresVectorStore(new EmbeddingModel());
$store->addTexts($chunks);
```

---

⚖️ LaraChain vs. LangChain (For Laravel)
----------------------------------------

[](#️-larachain-vs-langchain-for-laravel)

FeatureLangChain (Python/JS)**LaraChain (PHP/Laravel)****Syntax**Pipe Operator (`|`)Fluent `.pipe()` Method**Integration**Ad-hocNative Service Providers / Facades**I/O**GeneralLaravel FileSystem / DB Facades**Agents**LangGraphReAct / Future LaraGraph**Models**Custom DriversLaravel AI SDK (Native)---

📈 Use Cases
-----------

[](#-use-cases)

1. **Semantic Document Search**: Build a "Chat with your PDF" app in minutes using `RecursiveSplitter` and `PostgresVectorStore`.
2. **Autonomous Code Auditor**: Use the `FileToolkit` and `AgentExecutor` to scan your repository for security flaws.
3. **Structured Data Extraction**: Pipe raw OCR text through a `ChatModel` and `JsonParser` to ingest invoices into your database.

---

🛠️ Installation &amp; Setup
---------------------------

[](#️-installation--setup)

```
composer require subhashladumor1/larachain
php artisan vendor:publish --tag="larachain-config"
```

Refer to [LARACHAIN\_VERIFICATION\_2026.md](LARACHAIN_VERIFICATION_2026.md) for detailed verification of all 2026 market features.

---

🛠️ Multi-Provider Management
----------------------------

[](#️-multi-provider-management)

LaraChain uses a **Driver-based Architecture** (similar to Laravel's Database or Mail systems). You can configure and switch between providers at runtime.

### 1. Configuration (`config/larachain.php`)

[](#1-configuration-configlarachainphp)

Define multiple LLM, Vector, and Embedding providers:

```
'default' => [
    'llm' => 'openai',
    'vectorstore' => 'postgres',
],

'llms' => [
    'openai' => ['model' => 'gpt-4o'],
    'anthropic' => ['model' => 'claude-3-5-sonnet'],
],
```

### 2. Switching Providers at Runtime

[](#2-switching-providers-at-runtime)

Use the `LaraChain` facade to swap drivers dynamically:

```
// Use Anthropic instead of the default OpenAI
$model = LaraChain::model('anthropic');

// Use a specific vector store
$vectorStore = LaraChain::vectors()->driver('memory');

// Chain them together
$chain = PromptTemplate::make('Hello {name}')
    ->pipe($model)
    ->pipe(new JsonParser());
```

---

⚙️ Configuration
----------------

[](#️-configuration)

Contributions are welcome! Pull requests for new Vector Drivers (Pinecone, Qdrant) are prioritized.

📄 License
---------

[](#-license)

The MIT License (MIT). See [License File](LICENSE.md).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance88

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

65d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f38ba994870f0b2c8855e3f4614b1a8ecfecda7114fa4a8d261b9c6bb192b20b?d=identicon)[subhashladumor1](/maintainers/subhashladumor1)

---

Top Contributors

[![subhashladumor1](https://avatars.githubusercontent.com/u/79623012?v=4)](https://github.com/subhashladumor1 "subhashladumor1 (7 commits)")

---

Tags

laravellaravel-aiai-agentsintelligent-agentsvector-searchlarachainai-orchestrationlangchain-phpllm-chainsrag-frameworkai-automation

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/subhashladumor1-larachain/health.svg)

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

###  Alternatives

[laravel/tinker

Powerful REPL for the Laravel framework.

7.4k423.8M1.8k](/packages/laravel-tinker)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k96.9M674](/packages/laravel-socialite)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.2k84.2M225](/packages/laravel-horizon)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[laravel/sail

Docker files for running a basic Laravel application.

1.9k186.9M1.0k](/packages/laravel-sail)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)

PHPackages © 2026

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