silarhi / llms-txt-bundle
Build, dump and serve an llms.txt file from your Symfony application, the PrestaSitemapBundle way.
Package info
github.com/silarhi/llms-txt-bundle
Type:symfony-bundle
pkg:composer/silarhi/llms-txt-bundle
Requires
- php: >=8.2
- symfony/framework-bundle: ^6.4 || ^7.0 || ^8.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.54.0
- friendsofphp/php-cs-fixer: ^3.95.27
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan: ^2.3.1
- phpstan/phpstan-strict-rules: ^2.1.0
- phpstan/phpstan-symfony: ^2.1.0
- phpunit/phpunit: ^11.5.57 || ^12.5.38 || ^13.4.1
- rector/rector: ^2.7.0
- symfony/browser-kit: ^6.4 || ^7.0 || ^8.0
- symfony/console: ^6.4 || ^7.0 || ^8.0
- symfony/css-selector: ^6.4 || ^7.0 || ^8.0
- symfony/twig-bundle: ^6.4 || ^7.0 || ^8.0
- symfony/web-link: ^6.4 || ^7.0 || ^8.0
Suggests
- silarhi/cursor-pagination: Reads the large Doctrine result sets of LlmsTxtPopulateEvent listeners by keyset pages, with a flat memory
- symfony/console: Required for the llms-txt:dump command
- symfony/twig-bundle: Required for the llms_txt_url() and llms_txt_link() Twig functions
- symfony/web-link: Required for the Link header of the discovery.link_header option
Provides
None
Conflicts
None
Replaces
None
README
LLMs.txt Bundle
Build, dump and serve an llms.txt file from your Symfony application.
The PrestaSitemapBundle way: listeners fill it, a controller serves it, a command dumps it.
📖 Documentation
Features
- Event driven: listeners of
LlmsTxtPopulateEventadd the links, from your repositories, likeSitemapPopulateEvent - Route options: static pages join the file with an
llms_txtroute option, like thesitemapone - On the fly or dumped: the controller serves the dumped file when there is one, and builds it otherwise
- Flat memory: links added as generators are read one at a time, streamed to the response or the dumped file
- Spec compliant: H1 title, blockquote summary, H2 sections of links, the
Optionalsection always last, escaped links - Discovery: a
<link>tag for the<head>of your pages and an opt-inLinkheader, through WebLink
Requirements
- PHP 8.2+
- Symfony 6.4, 7.x or 8.x
Installation
composer require silarhi/llms-txt-bundle
Import the route serving /llms.txt:
# config/routes/llms_txt.yaml llms_txt: resource: '@LlmsTxtBundle/config/routes.php'
Quick start
# config/packages/llms_txt.yaml llms_txt: title: 'SILARHI' summary: 'Web and mobile applications, from design to maintenance.'
use Silarhi\LlmsTxtBundle\Routing\LlmsTxtEntry; #[Route('/contact', name: 'contact', options: ['llms_txt' => new LlmsTxtEntry(title: 'Contact')])] public function contact(): Response
GET /llms.txt now lists the contact page. Add the pages of your database from
an event listener, or dump the file with
php bin/console llms-txt:dump.
Documentation
Everything else is on llms-txt-bundle.silarhi.dev:
- Installation and configuration reference
- Adding links: event listeners, generators for large sections, route options
- Serving the file, on the fly or dumped
- Discovery:
<link>tag andLinkheader
Contributing
See CONTRIBUTING.md. Release notes are in CHANGELOG.md.
License
Released under the MIT License.