Download the PHP package schaefersoft/laravel-llms-txt without Composer
On this page you can find all versions of the php package schaefersoft/laravel-llms-txt. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download schaefersoft/laravel-llms-txt
More information about schaefersoft/laravel-llms-txt
Files in schaefersoft/laravel-llms-txt
Package laravel-llms-txt
Short Description Automatically generate llms.txt and llms-full.txt for Laravel applications
License MIT
Homepage https://github.com/schaefersoft/laravel-llms-txt
Informations about the package laravel-llms-txt
laravel-llms-txt
Automatically generate llms.txt and llms-full.txt files for your Laravel application — helping AI models understand your website, just like sitemap.xml helps search engines.
Built according to the llmstxt.org specification.
Requirements: PHP 8.2+ and Laravel 10, 11, 12, or 13.
Table of Contents
- Installation
- Quick Start
- Building Your Document
- Title and Description
- Sections and Entries
- Fluent Shorthand
- Conditional Content
- Configuration
- Routes
- Automatic Route Registration
- Excluding Routes from Auto-Generation
- Manual Route Registration
- Localization
- Translating Content
- Locale-Prefixed Routes
- Using mcamara/laravel-localization
- Static File Generation
- Artisan Command
- Programmatic Export
- llms-full.txt
- Serving llms-full.txt Dynamically
- Caching
- Output Format
- Testing
- License
Installation
Publish the configuration file:
That's it. The package is auto-discovered by Laravel, and /llms.txt is available immediately.
Quick Start
The package works in two modes:
-
Zero-config — Without any setup,
/llms.txtis automatically generated from all registeredGETroutes in your application. Internal routes (Telescope, Horizon, Debugbar) and routes with URI parameters are excluded. Additional routes can be excluded via theexclude_routesconfig option. - Custom definition (recommended) — Register a configure callback to have full control over the output. It always takes precedence over auto-generation.
This produces:
Tip: For larger projects, consider a dedicated
LlmsTxtServiceProviderto keep yourAppServiceProviderclean.
Building Your Document
Title and Description
Every document starts with a title and an optional description:
Both methods accept a string or a Closure for lazy evaluation (useful for localization):
Sections and Entries
Sections group related entries under a heading. Entries are links with a title, URL, and optional description.
Verbose style — useful when you need to store references to entries:
Fluent Shorthand
For a more compact style, use section() and entry() directly on the builder:
create()andmake()are identical — use whichever you prefer.Note: The
entry()shorthand returns theSection, not theEntry. To call methods on theEntryitself (e.g.description()), useEntry::create()withaddEntry()— or simply pass the description as the third argument toentry().
Model-Based Entries
Use entries() on a section to map a collection of models (or any iterable) into entries. The callback receives each item and must return an Entry instance.
You can combine entry() and entries() freely in the same section:
Conditional Content
Both LlmsTxt and Section support a when() method that mirrors Laravel's own when():
You can also pass a Closure as the condition for lazy evaluation:
Configuration
After publishing, the config file is at config/llms-txt.php:
| Option | Default | Description |
|---|---|---|
route_enabled |
true |
Enable or disable the HTTP routes entirely. |
llms_txt_route |
'/llms.txt' |
URL path for the standard file. |
llms_full_txt_route |
'/llms-full.txt' |
URL path for the full file. |
full_route_enabled |
false |
Serve llms-full.txt dynamically. Disabled by default — see llms-full.txt. |
register_routes |
true |
Auto-register routes. Set to false for manual registration. |
cache_enabled |
true |
Cache rendered output. |
cache_ttl |
3600 |
Cache lifetime in seconds. |
disk |
null |
Output location for static files. null writes directly into the public/ folder; set a disk name to use a filesystem disk. |
exclude_routes |
[] |
URI or route-name patterns (with * wildcards) to exclude from auto-generation. |
locales |
[] |
List of supported locales (e.g. ['en', 'de']). |
localize_routes |
false |
Register locale-prefixed routes like /en/llms.txt. |
Routes
Automatic Route Registration
By default, the package registers one route:
| Route | Description |
|---|---|
GET /llms.txt |
Serves the standard llms.txt output. |
A second route, GET /llms-full.txt, is only registered when full_route_enabled is set to true — see llms-full.txt for why it is opt-in.
Routes are registered automatically when register_routes is true (the default).
Excluding Routes from Auto-Generation
In zero-config mode the document is built from all registered GET routes. Use exclude_routes to keep specific routes out of the output. Patterns are matched against both the route URI and the route name, and support the * wildcard:
Manual Route Registration
To apply custom middleware or headers, disable automatic registration and call LlmsTxt::routes() yourself:
LlmsTxt::routes() is idempotent — it is safe to call more than once.
Localization
Translating Content
A single configure callback covers all locales. The package sets the application locale before invoking your callback, so __() and route() return the correct values automatically.
Create your language files as usual:
Locale-Prefixed Routes
Enable locale-prefixed routes to serve translated versions at /en/llms.txt, /de/llms.txt, etc.:
Unknown locale segments return a 404 response.
Using mcamara/laravel-localization
If you use mcamara/laravel-localization, disable automatic registration and wrap the routes in a localized group:
Static File Generation
Artisan Command
Generate static files with the llms:generate command:
By default, files are written directly into your application's public/ folder, so public/llms.txt is immediately served at https://your-app.test/llms.txt. To write to a filesystem disk instead (e.g. s3), set the disk config option.
Programmatic Export
You can also write files to disk from code:
llms-full.txt
The full variant fetches the content of each entry URL and appends it below the entry. URLs that cannot be fetched are silently skipped.
Serving llms-full.txt Dynamically
The /llms-full.txt route is disabled by default: on a cache miss it performs an HTTP request to every entry URL — which is slow, usually calls back into your own application, and lets any visitor trigger outbound traffic.
The recommended approach is generating a static file instead:
If you understand the trade-offs and want the dynamic route anyway, enable it explicitly:
With cache_enabled => true (the default), the fetched content is cached for cache_ttl seconds, so the entry URLs are only fetched once per TTL.
Caching
When cache_enabled is true (the default), rendered output is cached for the duration specified by cache_ttl.
You can also clear the cache from the command line:
Note:
php artisan llms:generateflushes the cache automatically after a successful run, so the dynamic routes immediately reflect the new content.
Output Format
llms.txt
llms-full.txt
Same structure as llms.txt, but with the fetched HTML/text content of each URL appended below its entry.
Testing
License
MIT — see LICENSE.
All versions of laravel-llms-txt with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/routing Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/filesystem Version ^10.0|^11.0|^12.0|^13.0
illuminate/cache Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.15.2 || ^8.0.1