PHPackages                             kambo/llama-cpp-php - 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. kambo/llama-cpp-php

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

kambo/llama-cpp-php
===================

The package enables the use of the LLama C++ library in PHP, thereby allowing the setup and execution of LLM models in PHP on your local machine.

v0.2.0-alpha(3y ago)473184[1 issues](https://github.com/kambo-1st/llama-cpp-php/issues)MITPHPPHP ^8.1

Since Apr 13Pushed 3y ago5 watchersCompare

[ Source](https://github.com/kambo-1st/llama-cpp-php)[ Packagist](https://packagist.org/packages/kambo/llama-cpp-php)[ Docs](https://github.com/kambo/llama-cpp-php)[ GitHub Sponsors](https://github.com/kambo-1st)[ RSS](/packages/kambo-llama-cpp-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Experimental bindings for LLama C++ library
===========================================

[](#experimental-bindings-for-llama-c-library)

[![Latest Version on Packagist](https://camo.githubusercontent.com/10d5e4a47c40b567504837be4c7fd24cdf78a2b3fe63eeb46c7ef2bfa9ae9860/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b616d626f2f6c6c616d612d6370702d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kambo/llama-cpp-php)[![Tests](https://camo.githubusercontent.com/cba1825cf9cdb4edd6bd2caac1db8cd351715eb21ff9dec08ef87559e2524c42/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b616d626f2d3173742f6c6c616d612d6370702d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/kambo-1st/llama-cpp-php/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/a0ebf3c8fcf1a079b4b7010101ea0737360bc819e8ebc50b4d9184ab86f0c04a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b616d626f2f6c6c616d612d6370702d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kambo/llama-cpp-php)

The package enables the use of the LLama C++ library in PHP, thereby allowing the setup and execution of LLM models in PHP on your local machine.

**This is highly experimental and not suitable for production use!**

**Use at your own risk!**

**Only Linux is supported!**

[![asciicast](llama-php.gif)](llama-php.gif)

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

[](#installation)

You can install the package via composer:

```
composer require kambo/llama-cpp-php kambo/llama-cpp-php-linux-lib
```

Note: the kambo/llama-cpp-php-linux-lib package contains a binary library for Linux.

Usage
-----

[](#usage)

Get model, you can use for example this command:

```
wget https://huggingface.co/LLukas22/gpt4all-lora-quantized-ggjt/resolve/main/ggjt-model.bin
```

```
$template = "You are a programmer, write PHP class that will add two numbers and print the result. Stop at class end.";
$context = Context::createWithParameter(new ModelParameters(__DIR__ .'/models/ggjt-model.bin'));
$llama = new LLamaCPP($context);
echo "Prompt: \033[0;32m".$template."\033[0m".PHP_EOL;

foreach ($llama->generate($template, new GenerationParameters(predictLength: 200)) as $token) {
    echo $token;
}
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

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 ~5 days

Total

3

Last Release

1120d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1073586?v=4)[Øystein Kambo Tangerås](/maintainers/kambo)[@kambo](https://github.com/kambo)

---

Top Contributors

[![kambo-1st](https://avatars.githubusercontent.com/u/6493048?v=4)](https://github.com/kambo-1st "kambo-1st (15 commits)")

---

Tags

kambollama-cpp-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kambo-llama-cpp-php/health.svg)

```
[![Health](https://phpackages.com/badges/kambo-llama-cpp-php/health.svg)](https://phpackages.com/packages/kambo-llama-cpp-php)
```

###  Alternatives

[phpro/soap-client

A general purpose SoapClient library

8885.6M46](/packages/phpro-soap-client)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

728272.9k20](/packages/civicrm-civicrm-core)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)[kambo/langchain

 ⚡ Building applications with LLMs through composability in PHP ⚡

3224.4k](/packages/kambo-langchain)

PHPackages © 2026

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