PHP code example of daikazu / laravel-llm-ready
1. Go to this page and download the library: Download daikazu/laravel-llm-ready 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/ */
daikazu / laravel-llm-ready example snippets
// Returns "https://yoursite.com/about.md" or null if excluded/disabled
$markdownUrl = llmReadyUrl();
// config/llm-ready.php
return [
// Enable/disable the package
'enabled' => env('LLM_READY_ENABLED', true),
// Cache settings
'cache' => [
'enabled' => env('LLM_READY_CACHE_ENABLED', true),
'ttl' => env('LLM_READY_CACHE_TTL', 1440), // 24 hours in minutes
'prefix' => 'llm_ready',
],
// CSS selectors to find main content (tried in order)
'content_selectors' => [
'main',
'article',
'[role="main"]',
'.content',
],
// Elements to remove before conversion
'ignore_selectors' => [
'nav',
'header',
'footer',
'aside',
'.sidebar',
'script',
'style',
],
// Eyebrow/label text detection
'eyebrow_selectors' => [
'.eyebrow',
'.overline',
'.kicker',
'[class*="eyebrow"]',
],
'eyebrow_auto_detect' => true,
// Routes to exclude from markdown conversion (supports nested paths)
'exclude_patterns' => [
'/admin/*', // Matches /admin/users, /admin/settings/email, etc.
'/api/*', // Matches /api/v1/users, /api/webhooks/stripe, etc.
'/livewire/*',
],
// Markdown discovery settings
'discovery' => [
'link_header' => env('LLM_READY_LINK_HEADER', true),
],
// llms.txt configuration (follows llmstxt.org spec)
'llms_txt' => [
'enabled' => true,
'cache_ttl' => 60,
'title' => env('LLM_READY_LLMS_TXT_TITLE'), // Defaults to app name
'summary' => env('LLM_READY_LLMS_TXT_SUMMARY'),
'description' => [],
'sections' => [
// 'Documentation' => [
// ['url' => '/docs/intro.md', 'description' => 'Introduction'],
// ],
],
'auto_section' => [
'enabled' => true,
'title' => 'Pages',
],
],
// YAML frontmatter settings
'frontmatter' => [
'
'llms_txt' => [
'title' => 'Acme Documentation',
'summary' => 'Complete documentation for the Acme platform.',
'description' => [
'Acme helps developers build better applications faster.',
'Our documentation covers installation, configuration, and advanced usage.',
],
'sections' => [
'Getting Started' => [
['url' => '/docs/installation', 'description' => 'How to install Acme'],
['url' => '/docs/quickstart', 'description' => '5-minute quickstart guide'],
],
'API Reference' => [
['url' => '/docs/api/authentication', 'description' => 'Authentication methods'],
['url' => '/docs/api/endpoints', 'description' => 'Available API endpoints'],
],
],
'auto_section' => [
'enabled' => true,
'title' => 'All Pages',
'
namespace App\LlmReady;
use Daikazu\LaravelLlmReady\Contracts\ContentExtractorInterface;
use DOMDocument;
class CustomContentExtractor implements ContentExtractorInterface
{
public function extract(DOMDocument $dom, array $contentSelectors, array $ignoreSelectors): string
{
// Your custom extraction logic
}
}
'extractor' => \App\LlmReady\CustomContentExtractor::class,
bash
php artisan vendor:publish --tag=llm-ready-config
nginx
location ~ \.md$ {
try_files /index.php?$query_string =404;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
bash
# Clear all LLM Ready caches
php artisan llm-ready:clear-cache
# Clear cache for a specific URL
php artisan llm-ready:clear-cache --url=https://yoursite.com/about-us
# Clear only the sitemap cache
php artisan llm-ready:clear-cache --sitemap