settermjd/mezzio-markdown-blog
Composer 安装命令:
composer create-project settermjd/mezzio-markdown-blog
包简介
This is a file-based blog module for PHP's Mezzio framework that renders blog articles written in Markdown format, with YAML front-matter into HTML content that can be rendered in a template.
README 文档
README
Mezzio Markdown Blog
This is a basic blog module for Mezzio applications, allowing you to get up and running with a blog in your applications pretty quickly.
How it works
When installed, the module adds two routes to the application’s routing table.
One to list all of the available blog items
Using the path /blog[/{current:\d+}], by default it lists the first page of the blog index.
However, if a page number is supplied current, then that page of the blog will be displayed.
Alternatively, the user can move forward and backward through pages of the blog by using the pagination links at the bottom of the current page.
It converts a series of Markdown files with Yaml front-matter into an array of BlogArticle entities, which are then rendered as HTML.
One to view individual blog items
Using the path /blog/item/{slug}, this route displays a blog item with the slug provided.
In addition to being able to view the matching blog item, a listing of one or more blog items that are related to the current item are also available, if any matches are available.
What do the Markdown files look like?
Here is a sample article, so that you know, roughly, what to expect.
---
publish_date: 13.07.2025
slug: episode-0001
synopsis: In this blogArticle, I have a fireside chat about one of my all-time favorite books, The Mythical Man Month.
title: Talking about The Mythical Man Month.
categories:
- software development
tags:
- Books
- Mythical Man Month
---
### Synopsis
Suspendisse viverra mauris ac urna gravida, vel malesuada dolor interdum. Nullam ultrices urna erat, non venenatis turpis placerat eget. Etiam vitae magna non tortor congue volutpat. Integer ut ornare ante. Etiam hendrerit vehicula turpis, sit amet pulvinar nunc dictum eu. In tincidunt sollicitudin eros, quis ultrices turpis maximus ut. Ut eu erat eget magna congue ornare vel et tortor. Curabitur laoreet neque et ex aliquet tempus.
### Related Links
- [The Mythical Man Month (on Wikipedia)][mythical-man-month-book-url]
| Note |
If an article is not explicitly marked as being a draft with the |
YAML Front-matter properties
| Property | Description | Default / Available Values | Required | Type |
|---|---|---|---|---|
categories |
Part of an article’s taxonomy, this is a list of categories for the article. Each one should be enclosed in double quotes, even if it is only one word. |
None. |
No |
List |
draft |
This indicates whether the article is in draft status or not. |
|
No |
Boolean |
image |
This is the post’s main image. It will be used with social shares, but otherwise isn’t used anywhere, at the moment. |
None. |
No |
String |
publish_date |
This is the date that the article will be published (go live) on. |
Dates can be in either of these two formats: "yyyy-mm-dd" or "dd.mm.yyyy". |
Yes |
String |
slug |
This is the article’s path, immediately following "/blog/item". |
It should follow standard slug syntax. |
Yes |
String |
synopsis |
This is the summary or synopsis of the article that appears alongside/underneath the heading. |
Yes |
String |
|
tags |
Part of an article’s taxonomy, this is a list of tags for the article. Each one should be enclosed in double quotes, even if it is only one word. tags |
None. |
No |
List |
title |
This is the article’s title. |
None. |
Yes |
String |
Usage
The package is designed to be used as part of Mezzio-based applications, and goes to a lot of effort to make doing so as simple as possible.
Install the package
To install the package, use Composer (just as you would install any other package) by running the following command:
composer require settermjd/mezzio-markdown-blog
During installation, the project’s ConfigProvider will be loaded into config/config.php, loading all of the required dependencies, routes, and template paths.
Given that, most of the work is done for you, including registering the routes and accompanying handlers for:
-
Listing all blog articles (the blog index page) — with pagination. The route is
/blog. -
Viewing individual blog articles. The route is
/blog/article/{slug}.
Set up the articles directory
There is no way to create the articles (posts) directory as part of the installation process, so you need to do this yourself.
So, in the data directory, create a new directory named posts.
The path needs to match the path element that you set in the application’s configuration, outlined in the previous section.
| Note |
In a future version, there will be tooling to automate this. |
Override the default templates
The next thing that you need to do is to override the blog templates. There are default versions in the project’s templates/blog directory. But these are quite generic and only meant as a way of quickly getting you started. They’re not designed to be a professional design for every application.
The three templates are:
-
blog.html.{{your view renderer extension}}. This template is the blog index page that renders all of the available articles or posts for your blog.
-
blog-article.html.{{your view renderer extension}}. This template renders details of a specific blog post when it is viewed.
-
includes/pagination.html.{{your view renderer extension}}, e.g., includes/pagination.html.twig. This is the pagination template which is called by the blog index template, so that users can step through the available blog records a page at a time.
| Note |
There are three versions of each template:
|
Update the application’s configuration (optional)
If you want or need to, you can also update the module’s configuration as well.
By default, its configuration is set in Settermjd\MarkdownBlog\ConfigProvider.
However, you can override this by copying the default configuration file, config/autoload/blog.local.php to the application’s config/autoload directory.
You can find documentation for each option in both the config file and in Settermjd\MarkdownBlog\ConfigProvider.
When using Twig as your view renderer
If you use Twig as your view renderer, while you don’t need to, you can create more feature-rich templates by installing PHP’s Intl extension, and the twig/markdown-extra and twig/intl-extra packages.
After installing PHP’s Intl extension using your package manager or from source, install the two Twig packages using the following command:
composer require twig/intl-extra twig/markdown-extra
settermjd/mezzio-markdown-blog 适用场景与选型建议
settermjd/mezzio-markdown-blog 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 205 次下载、GitHub Stars 达 9, 最近一次更新时间为 2025 年 10 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「blog」 「markdown」 「html」 「middleware」 「psr」 「psr-7」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 settermjd/mezzio-markdown-blog 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 settermjd/mezzio-markdown-blog 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 settermjd/mezzio-markdown-blog 相关的其它包
同方向 / 同关键字的高下载量 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
Laravel package for opinionated blog implementation
Adds more BBCode
HTML and form generation
Import an RSS-feed into blog
A modern HTML DOM parser for PHP using DOMDocument and Symfony CssSelector.
统计信息
- 总下载量: 205
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2025-10-10