PHP code example of schaefersoft / laravel-llms-txt
1. Go to this page and download the library: Download schaefersoft/laravel-llms-txt library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
schaefersoft / laravel-llms-txt example snippets
// app/Providers/AppServiceProvider.php
use SchaeferSoft\LaravelLlmsTxt\LlmsTxt;
public function boot(): void
{
LlmsTxt::configure(fn ($llms) => $llms
->title('My App')
->description('A short description of what this site offers.')
->section('Services', fn ($s) => $s
->entry('Web Development', 'https://example.com/web', 'Laravel & Vue.js')
->entry('Hosting', 'https://example.com/hosting', 'Managed hosting')
)
);
}
LlmsTxt::make()
->title('My App')
->description('Short tagline for the site.');
// Write to the default location
LlmsTxt::make()->title('My App')->writeToDisk();
// Write to a custom path
LlmsTxt::make()->title('My App')->writeToDisk('custom/path/llms.txt');
// Write with a locale prefix (writes to de/llms.txt)
LlmsTxt::make()->title('My App')->locale('de')->writeToDisk();
// Write the full version
LlmsTxt::make()->title('My App')->writeFullToDisk();
// Render as a string
$content = LlmsTxt::make()
->title('My App')
->section('Docs', fn ($s) => $s
->entry('API', 'https://example.com/api')
)
->renderFull();
// Write directly to disk
LlmsTxt::make()->title('My App')->writeFullToDisk();
// Use the default cache key ('llms-txt')
$content = LlmsTxt::make()->title('My App')->getCached();
// Use a custom cache key
$content = LlmsTxt::make()->title('My App')->getCached('my-custom-key');
// Flush ALL package cache keys (base keys + locale variants used by the routes)
LlmsTxt::make()->flushCache();
// Flush a single custom key
LlmsTxt::make()->flushCache('my-custom-key');