PHPackages                             hammrouni/nanoagent - 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. hammrouni/nanoagent

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

hammrouni/nanoagent
===================

NanoAgent is a lightweight library designed to strip away the complexity of modern AI development.

v0.1.0(5mo ago)015MITPHPPHP ^8.0CI failing

Since Jan 18Pushed 5mo agoCompare

[ Source](https://github.com/hammrouni/nanoagentphp)[ Packagist](https://packagist.org/packages/hammrouni/nanoagent)[ RSS](/packages/hammrouni-nanoagent/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (3)Used By (0)

NanoAgent PHP
=============

[](#nanoagent-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d870af0356643becc4005aabe7c1bbf11d8d1baadcd4c4d4227b850b3ca2b6cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616d6d726f756e692f6e616e6f6167656e743f7374796c653d666c61742d737175617265266c6f676f3d636f6d706f736572)](https://packagist.org/packages/hammrouni/nanoagent)[![Total Downloads](https://camo.githubusercontent.com/7930bbf49f42463b5cfe4c5e90f321941fcbf2164f90ada9bad80357c7edf408/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616d6d726f756e692f6e616e6f6167656e743f7374796c653d666c61742d737175617265266c6f676f3d7061636b6167697374)](https://packagist.org/packages/hammrouni/nanoagent)[![License](https://camo.githubusercontent.com/5b33cb6a2e830d9a5385abf5ad7b31bdda68ffcff518c354b5b06410783e3c6d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f68616d6d726f756e692f6e616e6f6167656e747068703f7374796c653d666c61742d73717561726526636f6c6f723d79656c6c6f77)](https://github.com/hammrouni/nanoagentphp/blob/main/LICENSE)[![PHP Version](https://camo.githubusercontent.com/2605fd811d2863cc5e0780c7b3e76881074db03238122a5cf209f7344d842586/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f68616d6d726f756e692f6e616e6f6167656e743f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://packagist.org/packages/hammrouni/nanoagent)[![GitHub Stars](https://camo.githubusercontent.com/97c5816ca248534c39feb6a63ce3ccbe55713cfe4e9e0a591ca05e113dd52f39/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f68616d6d726f756e692f6e616e6f6167656e747068703f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/hammrouni/nanoagentphp)[![GitHub Issues](https://camo.githubusercontent.com/55808fc3c9ce1d823aaa0a47b546d167665db86042e2e2e040804b77eefac42d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f68616d6d726f756e692f6e616e6f6167656e747068703f7374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/hammrouni/nanoagentphp/issues)

**Bring the power of LLMs to your PHP application—without the bloat.**

NanoAgent is a lightweight library designed to strip away the complexity of modern AI development. While other libraries force you into steep learning curves, massive dependency trees, and rigid architectural patterns, NanoAgent takes a different approach: **simplicity as a feature.**

Whether you are building a complex autonomous agent or just need to integrate smart decision-making into a project, NanoAgent lets you focus on the task, not the configuration.

Why NanoAgent?
--------------

[](#why-nanoagent)

The AI landscape is filled with "everything-included" frameworks that are often too heavy for practical, day-to-day PHP development.

- **Stop wrestling with complex configurations:** No need to learn a new DSL (Domain-Specific Language) or manage a dozen config files.
- **Drop-in ready:** Works with Laravel, Symfony, Slim, or plain PHP scripts.
- **Zero friction:** Go from `composer install` to a working agent in minutes.

Features
--------

[](#features)

- **⚡ Adaptable**: Seamlessly switch between OpenAI, Groq, Anthropic, DeepSeek, and OpenRouter with a single line of config.
- **🛠️ Tool-First Architecture**: Give your AI "hands." Easily map PHP functions as tools that your agent can intelligently execute to interact with your database, APIs, or filesystem.
- **🎯 Goal-Oriented Execution**: Define clear, context-aware tasks. The agent handles the reasoning, you handle the results.
- **💎 Minimalist Design**: A tiny footprint with massive potential. Use only what you need, with no hidden magic.

🚀 Quick Start
-------------

[](#-quick-start)

This guide provides step-by-step instructions for installing, configuring, and running the NanoAgent PHP library in any PHP environment.

### Prerequisites

[](#prerequisites)

- **PHP 8.0** or higher
- **Composer** installed globally

### 📦 Installation &amp; Setup

[](#-installation--setup)

1. Initialize a project:

    ```
    mkdir my-agent-project && cd my-agent-project
    composer require hammrouni/nanoagent
    ```
2. **Configuration** : Create `config.php` (copy the example from `NanoAgent/config.php.example`) in the project root to manage credentials.

    ```
    // config.php
    return [
        // API Key
        'api_key' => 'your_api_key_here',

        // AI Provider (groq, openai, anthropic, etc.)
        'provider' => '',

        // Model to use
        'model' => '',
    ];
    ```

    Then usage becomes:

    ```
    // index.php
    $config = require __DIR__ . '/config.php';

    $agent = new Agent(
        llm: $config
        // ... other parameters
    );
    ```
3. **Troubleshooting**

- **Class not found**: Run `composer dump-autoload` to regenerate the autoload files.
- **API Error**: Check `config.php` or your environment variables to ensure the API key is correct.
- **PHP Version**: Ensure you are running PHP 8.0+ by checking `php -v`.

🛠️ Advanced Usage: Tools
------------------------

[](#️-advanced-usage-tools)

Give your agent "hands" by defining tools.

```
use NanoAgent\Tools\FunctionTool;

$calculator = new FunctionTool(
    name: 'calculator',
    description: 'Add two numbers',
    parameters: [
        'type' => 'object',
        'properties' => [
            'a' => ['type' => 'integer', 'description' => 'First number'],
            'b' => ['type' => 'integer', 'description' => 'Second number']
        ],
        'required' => ['a', 'b']
    ],
    callable: fn(array $args) => $args['a'] + $args['b']
);

$agent = new Agent(
    llm: [...],
    tools: [$calculator]
);
```

📂 Examples
----------

[](#-examples)

Check the `examples/` directory for advanced use cases:

ExampleDescription**[Basic Usage](examples/basic.php)**Fundamental agent initialization and task execution.**[Chat](examples/chat.php)**Stateful conversation loop using PHP Sessions.**[Memory Chat](examples/memory_chat.php)**Persistent conversation history saved to JSON.**[Structured Output](examples/structured_output.php)**Extract JSON data from unstructured text.**[Knowledge Base](examples/knowledge_base_search.php)**RAG: Ask questions against private documents.**[Streaming](examples/streaming.php)**Real-time token streaming (SSE).**[Agent Chain](examples/agent_chain.php)**Multi-agent workflow (Researcher feeds Writer).**[Multi-Tool](examples/multi_tool_workflow.php)**Orchestrate multiple tools to solve complex requests.**[Advanced Tools](examples/advanced_tools.php)**Complex multi-step tool usage with simulated database state.**[API Integration](examples/api_integration.php)**Fetch real-world data from external APIs.**[Multi-Provider](examples/multi_provider.php)**Switch between different AI providers programmatically.Supported Providers
-------------------

[](#supported-providers)

- Groq
- OpenAI (not tested)
- OpenRouter (not tested)
- Anthropic (not tested)
- DeepSeek (not tested)

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance71

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

 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

165d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5824570?v=4)[Khaled HAMMROUNI](/maintainers/hammrouni)[@hammrouni](https://github.com/hammrouni)

---

Top Contributors

[![hammrouni](https://avatars.githubusercontent.com/u/5824570?v=4)](https://github.com/hammrouni "hammrouni (9 commits)")

---

Tags

aiai-agentai-agentsai-toolsphp-library

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hammrouni-nanoagent/health.svg)

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

PHPackages © 2026

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