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.
Package info
github.com/settermjd/mezzio-markdown-blog
Type:project
pkg:composer/settermjd/mezzio-markdown-blog
Fund package maintenance!
Requires
- php: ~8.3.0||~8.4.0
- composer/package-versions-deprecated: ^1.11.99.5
- laminas/laminas-component-installer: ^3.5.0
- laminas/laminas-config-aggregator: ^1.18.0
- laminas/laminas-diactoros: ^3.6.0
- laminas/laminas-hydrator: ^4.16.0
- laminas/laminas-inputfilter: ^2.33.0
- laminas/laminas-servicemanager: ^3.23.1
- mezzio/mezzio: ^3.21.0
- mezzio/mezzio-fastroute: ^3.13.0
- mezzio/mezzio-helpers: ^5.18.0
- mezzio/mezzio-laminasviewrenderer: ^2.18
- mezzio/mezzio-platesrenderer: ^2.12
- mezzio/mezzio-twigrenderer: ^2.17.0
- michelf/php-markdown: ^2.0.0
- mnapoli/front-yaml: dev-add-php-8.4-support
- monolog/monolog: ^3.9
- psr/cache: ^3.0
- psr/simple-cache: ^3.0
- samdark/sitemap: ^2.4
- twig/intl-extra: ^3.21
- twig/markdown-extra: ^3.21
- zetacomponents/feed: ^1.4.5
Requires (Dev)
- filp/whoops: ^2.18.4
- friendsofphp/php-cs-fixer: ^3.85.1
- laminas/laminas-coding-standard: ^3.1.0
- laminas/laminas-development-mode: ^3.14.0
- mezzio/mezzio-tooling: ^2.11.0
- mikey179/vfsstream: ^1.6.12
- mockery/mockery: ^1.6.12
- phpstan/phpdoc-parser: ^2.2
- phpstan/phpstan: ^2.1.22
- phpstan/phpstan-deprecation-rules: ^2.0.3
- phpstan/phpstan-phpunit: ^2.0.7
- phpunit/phpunit: ^12.3.4
- psalm/plugin-phpunit: ^0.19.5
- rector/rector: ^2.1.2
- roave/security-advisories: dev-master
- symfony/dom-crawler: ^7.3
This package is auto-updated.
Last update: 2026-07-13 11:34:28 UTC
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