rockstarcode/markdb
Composer 安装命令:
composer require rockstarcode/markdb
包简介
Markdown flat file database
README 文档
README
MarkDB - MarkDown Database for Blogs/CMSs
MarkDB is an engine that allows you to use MarkDown + Yaml files as data points for your CMS or Blog.
The intent is allow you to separate content creation from the platform which controls your application design. This allows you to write your blog or project in any method you'd like and attach content as if it were database driven.
This project stemmed from my blog at RockstarCode where I didnt want to have to design my site via a CMS like OctoberCMS or Wordpress which would force me to write posts via their interface, nor did I want to store content in a database which needed to be sync'd.
The solution I chose was to create a flat file .git repo to house my articles and MarkDB was the interface to collect and manage posts.
This allows me to write posts and preview them locally before pushing them to different environments by simple git push.
Features
- Pretty URL slug to identify files or directories
- Customize settings per file/directory
- Use a git repo to version control your data points
- Simple search for articles via attributes
- [FUTURE] - caching
Libraries vs Articles
MarkDB will look for files and directories given a $base path
From there it will provide a list of Libraries (directories) and Articles (Files)
Libraries hold collections of child libraries and all child articles to allow you to loop thru if needed to create navigation. For example you may have a base blog with navigation on various topics [Rants, Tutorials, Personal Thoughts] Your base new MarkDB('/path/to/blog/data') would house 3 libraries Rants, Tutorials, Personal Thoughts which you can use to pull unique data from or link to
Articles house file information in both YAML & MarkDown which you can use to customize data and presentation.
--- title: Article Title author: Authr Name author_email: Author@Email.com authdeck: author.name --- ### Hello World This is my article
Everything between --- will be processed as yaml, below the second --- will be processed as markdown
Requirements
LibYaml & pecl yaml for PHPUpdated to symfony/yaml to remove dependency- Carbon for data time
Installation
composer require "rockstarcode/markdb:dev-master"
Usage
$MarkDb = new MarkDB\MarkDB('/path/to/files/','base/path/to/form/relative/slugs'); $slug = 'path/to/some/article'; $article = $MarkDb->get($slug); # (object) Article $article->slug # url friendly path that identifies article in MarkDB $article->{$property} # properties extracted from YAML processing of the article $article->content() # processed MarkDown of content of article $article->read_time() # helper to calculate words in article and average read time $article->summary() # Extract certain percentage of content for preview $find = $MarkDb->where(['author'=>'Author Name','category'=>'Books Ive Read']); (Array)[Articles] foreach($MarkDb->libraries as $library){ $library->articles # list of articles within library $library->libraries # list of child libraries $library->index # list of all libraries/articles by slug $library->slug # slug which identifies library }
Laravel
MarkDB comes with a Laravel 5.* Service Provider which will add MarkDB as a facade to your application
# .env MARKDB_PATH=/path/to/blog-cms # config/app.php 'providers'=>[ ... \MarkDb\Support\Laravel\MarkDBServiceProvider::class, ], 'aliases' => [ ... 'MarkDb' => \MarkDB\Support\Laravel\MarkDBFacade::class, ]
a sample route to see articles in Laravel :
#routes.php Route::get('/posts, ['as'=>'posts','uses'=>function($slug){ $markdb= app()->make('markdb'); $articles = $cms->articles( /*optional*/ ['page'=>1, 'limit'=>10]); return view('index',['articles'=>$articles]); }])->where('slug','(.*)'); Route::get('/posts/{slug}', ['as'=>'post','uses'=>function($slug){ $article = \MarkDB::get($slug); return view('article',['article'=>$article]); }])->where('slug','(.*)');
Tutorial
I created a simple Lumen + MarkDB tutorial which steps you thru basic usage
License
Released under MIT license, feel free to use, modify, contribute changes.
rockstarcode/markdb 适用场景与选型建议
rockstarcode/markdb 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 284 次下载、GitHub Stars 达 9, 最近一次更新时间为 2015 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 rockstarcode/markdb 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rockstarcode/markdb 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 284
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-27