PHPackages                             php-llm/llm-chain-bundle - 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. php-llm/llm-chain-bundle

Abandoned → [symfony/ai-bundle](/?search=symfony%2Fai-bundle)ArchivedSymfony-bundle[Framework](/categories/framework)

php-llm/llm-chain-bundle
========================

Symfony integration bundle for php-llm/llm-chain

0.25.0(10mo ago)3732.5k↓27.1%7[6 issues](https://github.com/php-llm/llm-chain-bundle/issues)MITPHPPHP &gt;=8.2CI failing

Since Sep 22Pushed 10mo ago4 watchersCompare

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

READMEChangelog (10)Dependencies (9)Versions (41)Used By (0)

LLM Chain Bundle
================

[](#llm-chain-bundle)

Important

**PHP LLM becomes Symfony AI** - this project moved to [github.com/symfony/ai](https://github.com/symfony/ai). Please use the new repository for all future development, issues, and contributions. Thanks for your contributions - we hope to see you at Symfony AI!

Symfony integration bundle for [php-llm/llm-chain](https://github.com/php-llm/llm-chain) library.

Installation
------------

[](#installation)

```
composer require php-llm/llm-chain-bundle
```

Configuration
-------------

[](#configuration)

### Basic Example with OpenAI

[](#basic-example-with-openai)

```
# config/packages/llm_chain.yaml
llm_chain:
    platform:
        openai:
            api_key: '%env(OPENAI_API_KEY)%'
    chain:
        default:
            model:
                name: 'GPT'
```

### Advanced Example with Anthropic, Azure, Google and multiple chains

[](#advanced-example-with-anthropic-azure-google-and-multiple-chains)

```
# config/packages/llm_chain.yaml
llm_chain:
    platform:
        anthropic:
            api_key: '%env(ANTHROPIC_API_KEY)%'
        azure:
            # multiple deployments possible
            gpt_deployment:
                base_url: '%env(AZURE_OPENAI_BASEURL)%'
                deployment: '%env(AZURE_OPENAI_GPT)%'
                api_key: '%env(AZURE_OPENAI_KEY)%'
                api_version: '%env(AZURE_GPT_VERSION)%'
        google:
            api_key: '%env(GOOGLE_API_KEY)%'
    chain:
        rag:
            platform: 'llm_chain.platform.azure.gpt_deployment'
            structured_output: false # Disables support for "output_structure" option, default is true
            model:
                name: 'GPT'
                version: 'gpt-4o-mini'
            system_prompt: 'You are a helpful assistant that can answer questions.' # The default system prompt of the chain
            include_tools: true # Include tool definitions at the end of the system prompt
            tools:
                # Referencing a service with #[AsTool] attribute
                - 'PhpLlm\LlmChain\Chain\Toolbox\Tool\SimilaritySearch'

                # Referencing a service without #[AsTool] attribute
                - service: 'App\Chain\Tool\CompanyName'
                  name: 'company_name'
                  description: 'Provides the name of your company'
                  method: 'foo' # Optional with default value '__invoke'

                # Referencing a chain => chain in chain 🤯
                - service: 'llm_chain.chain.research'
                  name: 'wikipedia_research'
                  description: 'Can research on Wikipedia'
                  is_chain: true
        research:
            platform: 'llm_chain.platform.anthropic'
            model:
                name: 'Claude'
            tools: # If undefined, all tools are injected into the chain, use "tools: false" to disable tools.
                - 'PhpLlm\LlmChain\Chain\Toolbox\Tool\Wikipedia'
            fault_tolerant_toolbox: false # Disables fault tolerant toolbox, default is true
    store:
        # also azure_search, mongodb and pinecone are supported as store type
        chroma_db:
            # multiple collections possible per type
            default:
                collection: 'my_collection'
    embedder:
        default:
            # platform: 'llm_chain.platform.anthropic'
            # store: 'llm_chain.store.chroma_db.default'
            model:
                name: 'Embeddings'
                version: 'text-embedding-ada-002'
```

Usage
-----

[](#usage)

### Chain Service

[](#chain-service)

Use the `Chain` service to leverage GPT:

```
use PhpLlm\LlmChain\ChainInterface;
use PhpLlm\LlmChain\Model\Message\Message;
use PhpLlm\LlmChain\Model\Message\MessageBag;

final readonly class MyService
{
    public function __construct(
        private ChainInterface $chain,
    ) {
    }

    public function submit(string $message): string
    {
        $messages = new MessageBag(
            Message::forSystem('Speak like a pirate.'),
            Message::ofUser($message),
        );

        return $this->chain->call($messages);
    }
}
```

### Register Tools

[](#register-tools)

To use existing tools, you can register them as a service:

```
services:
    _defaults:
        autowire: true
        autoconfigure: true

    PhpLlm\LlmChain\Chain\Toolbox\Tool\Clock: ~
    PhpLlm\LlmChain\Chain\Toolbox\Tool\OpenMeteo: ~
    PhpLlm\LlmChain\Chain\Toolbox\Tool\SerpApi:
        $apiKey: '%env(SERP_API_KEY)%'
    PhpLlm\LlmChain\Chain\Toolbox\Tool\SimilaritySearch: ~
    PhpLlm\LlmChain\Chain\Toolbox\Tool\Tavily:
      $apiKey: '%env(TAVILY_API_KEY)%'
    PhpLlm\LlmChain\Chain\Toolbox\Tool\Wikipedia: ~
    PhpLlm\LlmChain\Chain\Toolbox\Tool\YouTubeTranscriber: ~
```

Custom tools can be registered by using the `#[AsTool]` attribute:

```
use PhpLlm\LlmChain\Chain\Toolbox\Attribute\AsTool;

#[AsTool('company_name', 'Provides the name of your company')]
final class CompanyName
{
    public function __invoke(): string
    {
        return 'ACME Corp.'
    }
}
```

The chain configuration by default will inject all known tools into the chain.

To disable this behavior, set the `tools` option to `false`:

```
llm_chain:
    chain:
        my_chain:
            tools: false
```

To inject only specific tools, list them in the configuration:

```
llm_chain:
    chain:
        my_chain:
            tools:
                - 'PhpLlm\LlmChain\Chain\Toolbox\Tool\SimilaritySearch'
```

### Profiler

[](#profiler)

The profiler panel provides insights into the chain's execution:

[![Profiler](./profiler.png)](./profiler.png)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance51

Moderate activity, may be stable

Popularity39

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60.9% 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 ~8 days

Total

36

Last Release

306d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e644c6c1e90b7d997edd1c25da41c48a76d89b7449fb5788214b341e2cd1a019?d=identicon)[chr-hertel](/maintainers/chr-hertel)

---

Top Contributors

[![chr-hertel](https://avatars.githubusercontent.com/u/2852185?v=4)](https://github.com/chr-hertel "chr-hertel (56 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (30 commits)")[![valtzu](https://avatars.githubusercontent.com/u/652734?v=4)](https://github.com/valtzu "valtzu (3 commits)")[![d0niek](https://avatars.githubusercontent.com/u/9316891?v=4)](https://github.com/d0niek "d0niek (1 commits)")[![DZunke](https://avatars.githubusercontent.com/u/1244235?v=4)](https://github.com/DZunke "DZunke (1 commits)")[![welcoMattic](https://avatars.githubusercontent.com/u/773875?v=4)](https://github.com/welcoMattic "welcoMattic (1 commits)")

---

Tags

llmphpsymfony

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-llm-llm-chain-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/php-llm-llm-chain-bundle/health.svg)](https://phpackages.com/packages/php-llm-llm-chain-bundle)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)

PHPackages © 2026

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