spatie/laravel-markdown-response 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

spatie/laravel-markdown-response

Composer 安装命令:

composer require spatie/laravel-markdown-response

包简介

Serve markdown versions of your HTML pages to AI agents and bots

README 文档

README

Logo for laravel-markdown-response

Serve markdown versions of your HTML pages to AI agents and bots

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

AI agents increasingly consume web content. This package lets your Laravel app serve markdown versions of HTML pages. Markdown requests are detected via Accept: text/markdown header, known AI user agent patterns, or .md URL suffix. The conversion is driver-based (local PHP or Cloudflare Workers AI), results are cached, and HTML can be preprocessed before conversion.

Here's a quick example:

use Spatie\MarkdownResponse\Middleware\ProvideMarkdownResponse;

Route::middleware(ProvideMarkdownResponse::class)->group(function () {
    Route::get('/about', [PageController::class, 'show']);
    Route::get('/posts/{post}', [PostController::class, 'show']);
});

Now when an AI agent visits /about or a user visits /about.md, they receive a clean markdown version of the page.

You can also convert HTML to markdown directly:

use Spatie\MarkdownResponse\Facades\Markdown;

$markdown = Markdown::convert($html);

And test your conversions:

use Spatie\MarkdownResponse\Facades\Markdown;

it('converts the about page to markdown', function () {
    Markdown::fake();

    $this->get('/about.md')->assertOk();

    Markdown::assertConverted();
});

Support us

We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.

Documentation

All documentation is available on our documentation site.

Testing

You can run the tests with:

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 49.31k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 73
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 73
  • Watchers: 0
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固