Download the PHP package stolt/llms-txt-php without Composer

On this page you can find all versions of the php package stolt/llms-txt-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package llms-txt-php

llms-txt-php

Test Status Version Downloads PHP Version PDS Skeleton Lean dist package

A PHP library for creating, parsing, validating, discovering, and expanding /llms.txt files.

Build and consume machine-readable Markdown context for LLMs and AI agents with a focused PHP API and no Composer runtime dependencies.

Why llms-txt-php?

llms.txt is an emerging Markdown-based convention for providing LLMs and AI agents with a concise, structured overview of a website, project, or documentation set.

llms-txt-php gives PHP applications one API for working with that format:

For the current specification, see llmstxt.org and the AnswerDotAI/llms-txt repository.

Installation

Install the package with Composer:

Quick start

Create a llms.txt

The generated document follows the familiar llms.txt structure:

Write the document directly to a file with toFile():

Parse and read

Parse a file or Markdown string with LlmsTxt:

The parser can also be used directly when you want a focused parsing API:

Parsing preserves the Markdown of the details content, including its meaningful line and paragraph structure. Transport-level differences such as a UTF-8 BOM and CRLF/CR line endings are normalized.

Validate

The specification requires a title. The description, details, and file lists are recommended.

For a simple validity check:

For detailed errors and warnings:

Use errors() for validation errors and warnings() for recommended elements that are missing.

The Optional section

The second version of the specification no longer gives the Optional section mechanical semantics. It remains a convention for secondary links.

optional() and getOptional() provide direct access without requiring callers to know the section name:

The section is named Optional automatically. Setting it replaces an existing Optional section.

The accessor also works with parsed documents.

Discovery

Version two of the specification introduced link relations that allow agents to discover Markdown representations and the llms.txt file covering a page.

Discovery supports:

Generate discovery links

The generated HTML is:

The generated header value can be passed directly to PHP's header() function:

Read discovery links

Resolve Markdown and covering URLs

A page can expose its Markdown representation by appending .md or replacing its extension with .md:

A llms.txt file covers pages below its path. The most specific covering file wins:

Combine discovery and parsing

Discovery locates resources while LlmsTxt parses them.

For example, an application can follow a describedby relation and parse the discovered document:

When serving pages, the same API can be used to announce the covering llms.txt together with the page's Markdown representation:

Expand into LLM context

Linked documents can be expanded into an XML LLM context file.

By default, all sections are expanded. Pass true to skip the conventional Optional section:

Custom fetchers

The default fetcher reads local files and otherwise uses PHP streams.

Pass a callable when you want to use a custom HTTP client, provide fixtures in tests, or control how linked documents are resolved:

The same fetcher approach is available when generating llms-full.txt.

Generate llms-full.txt

Linked documents can also be expanded into a Markdown llms-full.txt document.

The generated document keeps the llms.txt header and expands each link into a ### block containing its details, source URL, and fetched document:

Skip the conventional Optional section with:

A custom fetcher can be supplied as the second argument, just like with toLlmContext().

Inline llms.txt in HTML

The library can embed llms.txt content in HTML using a text/llms.txt script element.

The result has the following form:

toEmbeddedInScriptTag() is available as an alias.

Extract llms.txt from HTML

Use Extractor to retrieve text/llms.txt blocks from HTML:

The result is an array of extracted Markdown strings:

You can also extract from a file:

Pass the parse flag when you want LlmsTxt objects instead of strings:

API overview

LlmsTxt

The main document API:

Section

Use Section to group links:

Link

Use Link to represent a Markdown file-list entry:

Discovery

Use Discovery for llms.txt discovery and Markdown URL resolution:

Extractor

Use Extractor to extract embedded text/llms.txt blocks:

LlmsTxtParser

Use LlmsTxtParser when you need the parser directly:

CLI

For command-line workflows, use the complementary stolt/llms-txt-php-cli package.

Install it as a development dependency:

The CLI currently provides commands for:

See the CLI repository for installation and usage details.

Examples and tests

The test suite contains additional usage examples and documents edge cases that are important when parsing and serializing llms.txt.

For implementation-level examples, see the tests directory.

Alternative libraries

If you are working in a Laravel application, you may also want to look at laravel-llms-txt.

AI disclaimer

This package is developed with the assistance of Artificial Intelligence (AI). AI tools are used throughout the development process, including code generation, documentation, testing, and maintenance.

While reasonable care is taken to review and validate AI-generated contributions, AI-generated code is not inherently correct, secure, or free of defects. All contributions remain subject to human review and project quality standards.

As with any software, use this package at your own risk. No guarantee is made regarding its fitness for a particular purpose, and the maintainers assume no liability for damages resulting from its use.

License

This library is licensed under the MIT license. Please see LICENSE.md for more details.

Changelog

All noteworthy changes are documented in the CHANGELOG.md.

Contributing

If you're considering contributing to this library, have a look at this repository's CONTRIBUTING.md for more advice.


All versions of llms-txt-php with dependencies

PHP Build Version
Package Version
Requires php Version ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0 || ~8.6.0
ext-dom Version *
ext-libxml Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package stolt/llms-txt-php contains the following files

Loading the files please wait ...