hyn/eloquent-markdown
Composer 安装命令:
composer require hyn/eloquent-markdown
包简介
Mix markdown, frontmatter and eloquent models to easily handle markdown files with meta information by treating them as objects.
README 文档
README
Ever felt like your markdown files could use meta information.. And once you've added frontmatter logic, whether it would be amazing to handle those files more humanely..
So let's combine markdown files, frontmatter and eloquent!
That something like the below:
{
"title": "Some elaborate .."
}
And of course your regular markdown nonsense.
Mutates into an object:
echo $page->title; // Some elaborate .. echo $page->getRenderedMarkdown(); // <p>And of course your regular markdown nonsense.</p> echo $page->getMarkdown(); // And of course your regular markdown nonsense. $page->setMarkdown('Foojaa'); // Yes update $page->markdown = 'Foobar'; // Or on the assigned property $page->save(); // Write the file to disk, YES!
Installation
composer require hyn/eloquent-markdown
Now create a model you want to use for markdown files:
class Page extends \Hyn\Eloquent\Markdown\Model {}
And setup the filesystem and markdown parser resolution, add in AppServiceProvider or somewhere:
use Hyn\Eloquent\Markdown\Model; use Hyn\Frontmatter\Parser; use cebe\markdown\Markdown; // .. public function register() { Model::setMarkdownParser(new Parser(new Markdown)); Model::setFilesystem($this->app->make('filesystem')->disk('content')); }
Set
contentto the disk you configured to load the markdown files from. Or instantiate your own filesystem instance.
Usage
So if you have a file some/foo.md, use Page::find('some/foo.md'); to create a Page object, where any frontmatter
meta information is stored as properties, the markdown contents are stored in the original state as the markdown property
and the generated html is assigned to the contents attribute.
Other stuff that works:
save()delete()- update the markdown property to renew the rendered content property automatically
hyn/eloquent-markdown 适用场景与选型建议
hyn/eloquent-markdown 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 143 次下载、GitHub Stars 达 4, 最近一次更新时间为 2016 年 12 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hyn/eloquent-markdown 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hyn/eloquent-markdown 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 143
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-12-14