PHPackages                             llms-generator/llms-generator - 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. llms-generator/llms-generator

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

llms-generator/llms-generator
=============================

PHP library to generate llms.txt and llms-full.txt files for any PHP project

v1.0.3(1mo ago)08↓88%MITPHPPHP &gt;=7.4

Since Jun 4Pushed 1mo agoCompare

[ Source](https://github.com/llms-generator/llms-generator)[ Packagist](https://packagist.org/packages/llms-generator/llms-generator)[ RSS](/packages/llms-generator-llms-generator/feed)WikiDiscussions master Synced 1w ago

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

llms-generator
==============

[](#llms-generator)

[![PHP](https://camo.githubusercontent.com/97a72bd92a4bbe8b2db95aa168a1491fa949e24a4cf18677caaa1a11c920bc5f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e342532422d373737424234)](https://php.net)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)

A PHP library to generate `llms.txt` and `llms-full.txt` files for any PHP project. Framework-agnostic — works with Laravel, Concrete CMS, WordPress, Symfony, and plain PHP sites.

Install
-------

[](#install)

If published on Packagist:

```
composer require llms-generator/llms-generator
```

Or install directly from GitHub:

```
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/llms-generator/llms-generator"
        }
    ],
    "require": {
        "llms-generator/llms-generator": "dev-main"
    }
}
```

Usage
-----

[](#usage)

```
use LlmsGenerator\Config;
use LlmsGenerator\LlmsGenerator;

$config = new Config([
    'base_url'    => 'https://example.com',
    'title'       => 'My Project',
    'description' => 'A short description for the blockquote.',
]);

$generator = new LlmsGenerator($config);

// Add pages manually
$generator->addPage('/docs/getting-started', [
    'title'   => 'Getting Started',
    'section' => 'Docs',
    'notes'   => 'How to install and configure',
]);
$generator->addPage('/docs/api', ['section' => 'Docs']);

// Or discover from sitemap
$generator->discoverFromSitemap();

// Generate both files
$result = $generator->generate();
// $result['llms.txt']      => /path/to/llms.txt
// $result['llms-full.txt'] => /path/to/llms-full.txt
```

How it works
------------

[](#how-it-works)

1. You register pages via `addPage()` or auto-discover from `sitemap.xml`
2. `generate()` fetches each page's HTML via HTTP
3. HTML is sanitized: nav, footer, aside, script, style, hr, select, option, input, button, and svg elements are removed; images are replaced with their alt or title text
4. Missing titles are parsed from `` tags
5. Missing sections are derived from URL path prefixes (`/docs/*` → `Docs`)
6. Sanitized HTML is converted to clean Markdown (ATX headings, stripped unknown tags, collapsed blank lines)
7. `llms.txt` is written with the project index (H1, blockquote, sections with links)
8. `llms-full.txt` is written with full page content inline, separated by `---`

Output examples
---------------

[](#output-examples)

### llms.txt

[](#llmstxt)

```
# My Project

> A short description for the blockquote.

## Docs

- [Getting Started](https://example.com/docs/getting-started): How to install and configure
- [API Reference](https://example.com/docs/api)

## Optional

- [Changelog](https://example.com/changelog)
```

### llms-full.txt

[](#llms-fulltxt)

```
# My Project

> A short description for the blockquote.

---

## Getting Started

URL: https://example.com/docs/getting-started

...full markdown content...

---

## API Reference

URL: https://example.com/docs/api

...full markdown content...
```

API
---

[](#api)

### `addPage(string $url, array $options = []): self`

[](#addpagestring-url-array-options---self)

OptionDefaultDescription`title`autoPage title. Parsed from `` if omitted`section`autoH2 section. Derived from URL prefix (`/docs/*` → `Docs`) if omitted`notes`nullDescription appended after the link in llms.txt### `discoverFromSitemap(?string $sitemapUrl = null): self`

[](#discoverfromsitemapstring-sitemapurl--null-self)

Fetches and parses `{base_url}/sitemap.xml` (or a custom URL) and registers all discovered pages.

### `generate(): array`

[](#generate-array)

Fetches all pages, converts to Markdown, writes both files. Returns `['llms.txt' => '/path', 'llms-full.txt' => '/path']`.

The constructor accepts optional implementations for testing or customization:

```
$generator = new LlmsGenerator(
    $config,
    $fetcher,      // FetcherInterface|null — HTTP fetcher (default: HttpFetcher)
    $converter,    // ConverterInterface|null — HTML-to-markdown (default: HtmlToMarkdownConverter)
    $sanitizer,    // SanitizerInterface|null — HTML sanitizer (default: HtmlSanitizer)
    $dumper        // FileDumper|null — file writer (default: FileDumper)
);
```

Config options
--------------

[](#config-options)

```
$config = new Config([
    'base_url'        => 'https://example.com',
    'title'           => 'My Project',
    'description'     => 'A blockquote summary.',
    'details'         => 'Optional free-form details after the blockquote.',
    'output_dir'      => getcwd(),
    'default_section' => 'Pages',
    'http_timeout'    => 30,
]);
```

Requirements
------------

[](#requirements)

- PHP 7.4+
- `ext-dom`*, `ext-simplexml`*, `ext-libxml`\* — bundled with PHP
- An HTTP client package (Guzzle, Symfony HttpClient, etc.) autodiscovered via `php-http/discovery`

\* These are required for DOM sanitization and sitemap parsing.

Contributing
------------

[](#contributing)

Pull requests are welcome. Open an [issue](https://github.com/llms-generator/llms-generator/issues) first for significant changes.

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 85.7% 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

4

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4865abc2506acabc3591df8998a8b13ad910d362ea330b6d8ed15a8d63cd37f?d=identicon)[llms-generator](/maintainers/llms-generator)

---

Top Contributors

[![madnanshah](https://avatars.githubusercontent.com/u/41105865?v=4)](https://github.com/madnanshah "madnanshah (6 commits)")[![llms-generator](https://avatars.githubusercontent.com/u/290673104?v=4)](https://github.com/llms-generator "llms-generator (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/llms-generator-llms-generator/health.svg)

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

758.5M9](/packages/chargebee-chargebee-php)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)[sylius/sylius

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

8.5k5.9M754](/packages/sylius-sylius)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

36789.4k2](/packages/telnyx-telnyx-php)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M425](/packages/drupal-core-recommended)

PHPackages © 2026

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