<!-- Generated from ar/llms-txt-laravel/index.html. The canonical document is the HTML page. -->

- [ الرئيسية ](/ar/) 
/
- [ كيفية إنشاء ](/ar/how-to-create/) 
/
- دليل Laravel            
# `llms.txt` لـ Laravel

دليل public/ في Laravel هو جذر الويب ولا يحتاج إلى إعداد. وللإنشاء الديناميكي، أضف مسارًا في routes/web.php أو وحدة تحكم مخصصة تستخدم واجهة Cache في Laravel.

آخر تحديث: 22 أبريل 2026

في هذه الصفحة

- [ الخيار 1: ملف ثابت في public/ ](#static)
- [ الخيار 2: مسار في routes/web.php ](#route)
- [ الخيار 3: متحكم مع التخزين المؤقت ](#controller)
- [ ماكرو للاستجابة قابل لإعادة الاستخدام ](#macro)
- [ تحقّق ](#verify)
- [ قائمة فحص قبل الشحن ](#checklist)              
تحذير

لا تستخدم قوالب Blade

لا تُرجع عرض Blade لـ  llms.txt . تضيف Blade تعليقات HTML ومسافات وإعلانات doctype
التي تكسر صيغة النص العادي. أعد دائماً  response()  مع  Content-Type: text/plain .

## الخيار 1: ملف ثابت في public/

يستخدم Laravel `public/` الدليل هو جذر الوثائق الذي يقدّمه nginx أو Apache. وأي ملف يوضع
فيه يتاح في مسار URL المطابق بلا إعداد توجيه. وهذا أبسط نهج ولا يتطلب أي تغيير في الرمز.
public/llms.txt, directory structure    نسخ     

```
# Laravel static file approach
#
# Laravel's public/ directory is the web root (served by nginx/Apache).
# Drop your file here and it is immediately available at /llms.txt.
#
# Project structure:
# your-laravel-app/
# ├── public/
# │   ├── index.php
# │   └── llms.txt   ← add this
# ├── routes/
# └── app/
#
# No code change needed. Works on Forge, Vapor, Heroku, and bare VPS.

```

يعمل هذا النهج مع جميع أهداف نشر Laravel: **Laravel Forge**, **Laravel Vapor**, **Heroku**, **Railway**، وخوادم VPS
العادية. يقدّم خادم الويب (nginx/Apache) الملف مباشرةً دون إشراك PHP، وهذا أسرع أيضًا.

## الخيار 2: مسار في routes/web.php

عندما تريد إنشاء المحتوى برمجياً أو إدارته من الكود بدلاً من ملف، أضف مساراً مُسمّى في `routes/web.php`:
routes/web.php    نسخ     

```
One-sentence description of what your site or product does.

## Documentation

- [Getting Started](https://yoursite.com/docs/start): Install and configure in minutes.
- [API Reference](https://yoursite.com/docs/api): Full endpoint catalog with examples.

## Product

- [Overview](https://yoursite.com/product): Core features and capabilities.
- [Pricing](https://yoursite.com/pricing): Plans and billing details.

## Optional

- [Changelog](https://yoursite.com/changelog): Release history.
LLMS;

return response($content, 200)
->header('Content-Type', 'text/plain; charset=utf-8')
->header('Cache-Control', 'public, max-age=3600, stale-while-revalidate=86400');
})->name('llms-txt');

```

استخدم صيغة heredoc في PHP (`  
مثال

موضع المسار

سجّل  /llms.txt  المسار قبل أي مسارات شاملة أو بديلة ( Route::fallback() )
لضمان مطابقة Laravel له بصورة صحيحة.

## الخيار 3: متحكّم مع التخزين المؤقت

للمحتوى المولّد ديناميكياً من قاعدة البيانات، مثل جلب صفحات التوثيق المنشورة، استخدم وحدة تحكم
قابلة للاستدعاء مخصصة مع `Cache::remember()` لتجنب استعلام قاعدة بيانات في كل طلب:
app/Http/Controllers/LlmsTxtController.php    نسخ     

```
buildContent();
});

return response($content, 200)
->header('Content-Type', 'text/plain; charset=utf-8')
->header('Cache-Control', 'public, max-age=3600, stale-while-revalidate=86400');
}

private function buildContent(): string
{
// You can query your database here:
// $docs = \App\Models\Doc::published()->get();
// $links = $docs->map(fn($d) => "- [{$d->title}](https://yoursite.com/docs/{$d->slug}): {$d->summary}")->join("\n");

return   One-sentence description of your product.

## Documentation

- [Getting Started](https://yoursite.com/docs/start): Install and configure in minutes.
- [API Reference](https://yoursite.com/docs/api): Full endpoint catalog with examples.

## Optional

- [Changelog](https://yoursite.com/changelog): Release history.
LLMS;
}
}

```
routes/web.php, controller registration    نسخ     

```
name('llms-txt');

```

`Cache::remember()` يخزّن النتيجة في مشغل التخزين المؤقت المضبوط لديك (Redis أو Memcached
أو قاعدة بيانات أو ملف). ويُعاد توليد التخزين المؤقت تلقائياً بعد 3600 ثانية. ولإبطاله فوراً بعد تحديث
المحتوى، استدعِ `Cache::forget('llms_txt')` في مراقب النموذج لديك أو بعد خطاف النشر.

## ماكرو للاستجابة قابل لإعادة الاستخدام

إذا كنت تقدّم عدة ملفات نصية عادية أو تريد نمطاً متسقاً عبر تطبيقك، فسجّل `plaintext()` ماكرو الاستجابة في `AppServiceProvider`:
app/Providers/AppServiceProvider.php    نسخ     

```
'text/plain; charset=utf-8',
'Cache-Control' => "public, max-age={$maxAge}, stale-while-revalidate=86400",
]);
});
}
}

// Usage in a route or controller:
// return response()->plaintext($content);

```

ويصبح الماكرو متاحاً في أي موضع من تطبيقك عبر `response()->plaintext($content)`، مع إبقاء `Content-Type` و `Cache-Control` اجعل الرؤوس متسقة.

## تحقّق

بعد النشر، تأكد من تقديم الملف بصورة صحيحة:
Verification    نسخ     

```
curl -I https://yoursite.com/llms.txt
# Expected:
# HTTP/2 200
# content-type: text/plain; charset=utf-8
# cache-control: public, max-age=3600

curl https://yoursite.com/llms.txt | head -5
# Should print: # Your Site
```

ثم الصق عنوان URL في [مدقّق llms.txt](/ar/validator/) للتحقق من التوافق الكامل مع المواصفة.

## قائمة فحص قبل الشحن

- الملف مقدَّم على `/llms.txt` مع `200 OK`. 
- `Content-Type: text/plain; charset=utf-8` تم ضبطه. 
- `Cache-Control` الرأس موجود. 
- الاستجابة نص عادي، بلا HTML وبلا مخرجات Blade. 
- عنوان H1 واحد بالضبط في الأعلى. 
- ملخص الاقتباس مباشرةً بعد H1. 
- كل عناوين URL مطلقة (`https://`). 
- لم تُطبَّق برمجية وسيطة للمصادقة على `/llms.txt` المسار. 
- يعيد المدقق بلا أخطاء: [llmtxt.info/validator/](/ar/validator/)   
## أدلة ذات صلة

- [كيفية إنشاء llms.txt](/ar/how-to-create/), والقوالب وقائمة الفحص. 
- [مرجع تنسيق llms.txt](/ar/llms-txt-format/), تفاصيل المواصفة. 
- [llms.txt لنظام إدارة محتوى بلا واجهة](/ar/llms-txt-cms/)وContentful وSanity
وStrapi. 
- [أفضل الممارسات](/ar/best-practices/)، وما ينبغي تضمينه وما ينبغي تخطيه. 
- [المدقّق](/ar/validator/) · [المولّد](/ar/generator/).        
## المصادر

- [ llmstxt.org، اقتراح المجتمع ](https://llmstxt.org/)
- [ توثيق Laravel، والتوجيه ](https://laravel.com/framework/docs/routing)
- [ توثيق Laravel، التخزين المؤقت ](https://laravel.com/framework/docs/cache)
