定制 thesimonharms/lontar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

thesimonharms/lontar

Composer 安装命令:

composer require thesimonharms/lontar

包简介

A minimal headless blog API package for Laravel with Markdown support.

README 文档

README

A minimal, headless blog API package for Laravel. Ships a Post model, full CRUD controller, and API routes. Stores post bodies as Markdown and renders them server-side via league/commonmark.

No opinions on auth, frontend, or theming — bring your own.

Requirements

  • PHP 8.2+
  • Laravel 11 or 12
  • laravel/sanctum installed in the consuming app (for authenticated endpoints)

Installation

composer require lontar/blog

The service provider is auto-discovered. Run migrations:

php artisan migrate

That's it. The API routes are registered automatically under /api.

Endpoints

Public

Method Endpoint Description
GET /api/posts Paginated list of published posts (title, slug, excerpt, published_at)
GET /api/posts/{slug} Full detail for a single published post

Posts with a null published_at or a future published_at are treated as drafts and excluded from public responses.

Authenticated (auth:sanctum)

Method Endpoint Description
GET /api/posts/drafts Paginated list of unpublished posts
POST /api/posts Create a new post
PUT /api/posts/{slug} Update a post
DELETE /api/posts/{slug} Delete a post
POST /api/posts/{slug}/publish Set published_at to now
POST /api/posts/{slug}/unpublish Set published_at to null

Request Bodies

POST /api/posts

{
    "title": "My Post Title",
    "body": "Markdown content here.",
    "excerpt": "Optional short summary.",
    "published_at": "2026-03-10T00:00:00Z"
}

slug is derived automatically from title. excerpt and published_at are optional — omit published_at to save as a draft.

PUT /api/posts/{slug}

Same fields as above, all optional. If title is updated, slug is regenerated.

Markdown

Post bodies are stored as raw Markdown. The Post model exposes a rendered_body attribute that converts the body to HTML on access via league/commonmark:

$post->rendered_body; // HTML string

Use this in your views when rendering post content. The raw body field is always available too.

Post Model

use Lontar\Blog\Models\Post;

// Published posts
Post::published()->get();

// All posts including drafts
Post::all();

// Find by slug
Post::where('slug', 'my-post')->firstOrFail();

The published scope filters to posts where published_at is not null and not in the future.

Auth

This package ships with auth:sanctum on write routes but does not install or configure Sanctum. Set it up in your consuming app:

composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate

Then ensure your api middleware group includes sanctum in bootstrap/app.php or app/Http/Kernel.php.

License

MIT

thesimonharms/lontar 适用场景与选型建议

thesimonharms/lontar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 22 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 thesimonharms/lontar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 thesimonharms/lontar 我们能提供哪些服务?
定制开发 / 二次开发

基于 thesimonharms/lontar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-21