sly/bloghub
Composer 安装命令:
composer require sly/bloghub
包简介
Use a Git repository to generate blog entities and contents. PlainText, HTML and Markdown formats supported.
README 文档
README
Use a Git repository to generate blog entities and contents.
=====
WORK IN PROGRESS.
=====
Requirements
- PHP 5.3+
Installation
Add to your project Composer packages
Just add sly/blog-hub package to the requirements of your Composer JSON configuration file,
and run php composer.phar install to install it.
Install from GitHub
Clone this library from Git with git clone https://github.com/Ph3nol/BlogHub.git.
Goto to the library directory, get Composer phar package and install vendors:
curl -s https://getcomposer.org/installer | php
php composer.phar install
You're ready to go.
Repository structure
Your git repository has to respect a Categories/Posts structure to be understood by the library.
The logic:
Category 1
`-- Title of my post 1
`-- Title of my post 2
`-- Title of my post 3
Category 2
`-- Title of my post 4
To match this logic, the repository tree will be:
Category 1/
Category 1/Title of my post 1.md
Category 1/Title of my post 2.md
Category 1/Title of my post 3.md
Category 2/
Category 2/Title of my post 4.md
Post structure
Each post has to be a markdown file, into a category folder. Informations can be added to it as PHPDoc/Annotations one. Here is an example:
/**
* @createdAt 2013-01-01
* @description This is my post description.
* @tags tag1, tag2, tag3
* @format markdown
*/
# My post title
My post content.
Example
require_once 'vendor/autoload.php'; use GitElephant\Repository; use Sly\BlogHub\Blog\Blog; /** * GitElephant repository instance. */ $repo = new Repository('/path/to/your/repository'); $repo->checkout('master'); /** * BlogHub instance, with repository object as argument. */ $blog = new Blog($repo);
Categories list
foreach ($blog->getCategories() as $category) { // Your logic }
Elements:
- Category name:
(string) $categoryor$category->getName() - Posts collection:
$category->getPosts() - Number of posts:
$category->getPosts()->count()
Posts list
foreach ($blog->getPosts() as $post) { // Your logic }
foreach ($category->getPosts() as $post) { // Your logic }
Elements:
- Post title:
(string) $postor$post->getTitle() - Post category object:
$post->getCategory() - Slug:
$post->getSlug() - Excerpt:
$post->getExcerpt([string $separator = ' [...]']) - Tags collection:
$post->getTags() - Creation DateTime:
$post->getCreatedAt() - Update DateTime:
$post->getUpdatedAt()
Tags list
foreach ($blog->getTags() as $tag) { // Your logic }
foreach ($post->getTags() as $tag) { // Your logic }
Elements:
- Tag name:
(string) $tagor$tag->getName()
Query Builder
You can use the QueryBuilder to retreive a specific model entity. Here is an example:
$query = $blog->getQuery(); // Get QueryBuilder from Blog Manager service $post = $query->from('Post')->getOneBySlug('hello-world'); // Get the Post from its slug
sly/bloghub 适用场景与选型建议
sly/bloghub 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 3, 最近一次更新时间为 2013 年 01 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「blog」 「git」 「markdown」 「repository」 「html」 「content」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sly/bloghub 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sly/bloghub 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sly/bloghub 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Texy converts plain text in easy to read Texy syntax into structurally valid (X)HTML. It supports adding of images, links, nested lists, tables and has full support for CSS. Texy supports hyphenation of long words (which reflects language rules), clickable emails and URL (emails are obfuscated again
Easily manage git hooks in your composer config
Laravel package for opinionated blog implementation
MediaWiki extension that allows embedding external content, specified by URL, into your wiki pages
Adds more BBCode
Nagios plugin to verify a git repository.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-01-06