PHPackages                             maglnet/magl-markdown - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. maglnet/magl-markdown

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

maglnet/magl-markdown
=====================

Provides a ZF2 View Helper to render markdown syntax. It uses third-party libraries for the rendering and you can switch between different renderers.

1.10.0(4y ago)22178.2k—4.1%7[1 issues](https://github.com/maglnet/MaglMarkdown/issues)4MITPHPPHP ^7.3 || ^8.0

Since Feb 22Pushed 4y ago4 watchersCompare

[ Source](https://github.com/maglnet/MaglMarkdown)[ Packagist](https://packagist.org/packages/maglnet/magl-markdown)[ Docs](https://github.com/maglnet/MaglMarkdown)[ RSS](/packages/maglnet-magl-markdown/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (18)Versions (24)Used By (4)

MaglMarkdown - ZF2 View Helper For Markdown
===========================================

[](#maglmarkdown---zf2-view-helper-for-markdown)

[![Build Status](https://camo.githubusercontent.com/1120f6fdc5987041a553e20d88dafa1fa2a087faf38fe7c1fded64ebd577adad/68747470733a2f2f7472617669732d63692e6f72672f6d61676c6e65742f4d61676c4d61726b646f776e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/maglnet/MaglMarkdown)[![Latest Stable Version](https://camo.githubusercontent.com/feee9ea134d7d5104617e7afdb5765d8d670e8c08a08cfbe13d8e7fb36fdeccd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61676c6e65742f6d61676c2d6d61726b646f776e2e737667)](https://packagist.org/packages/maglnet/magl-markdown)[![License](https://camo.githubusercontent.com/0ae1be0404c643606eede9742ae72fb1d4b31516658954cc2d55c179214771f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d61676c6e65742f6d61676c2d6d61726b646f776e2e737667)](https://packagist.org/packages/maglnet/magl-markdown)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0a10a9c2c71dd11aa3c9b87499976e5c16afdaf980cb7f789bd974bdf974dec9/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d61676c6e65742f4d61676c4d61726b646f776e2e737667)](https://scrutinizer-ci.com/g/maglnet/MaglMarkdown/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/9c37048388743b142e608621f431b3584b0bec3e993d8ac7a247fa756c261879/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d61676c6e65742f4d61676c4d61726b646f776e2e737667)](https://scrutinizer-ci.com/g/maglnet/MaglMarkdown/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/5d9e1ce532efd6c4518a1cebb6bfd5b8cfd96a90604bedb685367a8d61e6be63/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3533313036393631656331333735386237653030303063302f62616467652e737667)](https://www.versioneye.com/user/projects/53106961ec13758b7e0000c0)

Introduction
------------

[](#introduction)

MaglMarkdown is a ZF2 module that adds a View Helper to transform [Markdown](http://daringfireball.net/projects/markdown/). To change between different renderers have a look at the [config section](#configuration)

You can use one of the following parsers for your Markdown:

- The [PHP-Markdown](http://michelf.com/projects/php-markdown/) parser from Michel Fortin
- The [PHP-MarkdownExtra](http://michelf.ca/projects/php-markdown/extra/) parser from Michel Fortin (this is the default)
- The [Parsedown](http://parsedown.org/) parser from Emanuil Rusev
- The [Parsedown-Extra](http://parsedown.org/) parser from Emanuil Rusev
- [Github Markdown Api](https://guides.github.com/features/mastering-markdown/)
    - you should provide an access\_token within the config, to avoid hitting the [rate\_limit](https://developer.github.com/v3/rate_limit/) too soon
    - it's highly recommended to enable caching if you use the Github Api because of the mentioned rate\_limit and to boost performance
- The [PHP League's CommonMark](https://github.com/thephpleague/commonmark) implementation

Installation
------------

[](#installation)

You can install the module with composer by adding the following "require" to your `composer.json`

```
{
	"require": {
		"maglnet/magl-markdown": "~1.1"
	}
}
```

after that you need to run

```
$ php composer.phar update
```

and enable the module within your `application.config.php`

```
array(
	'modules' => array(
		'Application',
		'MaglMarkdown',
	),
);
```

Usage
-----

[](#usage)

### View Helper

[](#view-helper)

Simply use it within your Views like this

```
$this->markdown('Yes, **this** is *Markdown*!');
```

### Service Manager

[](#service-manager)

You can get the MarkdownService through the Service Manager, to use the `render()` method wherever you like within you zf2 application. `MarkdownService` automatically uses caching if it has been enabled within the config.

```
/* @var $markdownService MaglMarkdown\Service\Markdown */
$markdownService = $serviceManager->get('MaglMarkdown\MarkdownService');
$html = $markdownService->render('Yes, **this** is *Markdown*!');
```

You can also get a MarkdownAdapter through the Service Manager and use `transformText()` to get your Markdown rendered to HTML.
This is **NOT** recommended anymore. Use the above mentioned `MarkdownService` instead because it can use the provided caching mechanism.

```
/* @var $markdownAdapter MaglMarkdown\Adapter\MarkdownAdapterInterface */
$markdownAdapter = $serviceManager->get('MaglMarkdown\MarkdownAdapter');
$html = $markdownAdapter->transformText('Yes, **this** is *Markdown*!');
```

*Security warning:*
You should be aware, that your markdown could contain insecure content (e.g. user generated content). So use something like HTMLPurifier to sanitize your output.

Configuration
-------------

[](#configuration)

Copy the provided config file `config/maglmarkdown.local.php` to your autoloading directory `YourZF2Application/config/autoload/maglmarkdown.local.php` and adjust it to your needs.
By default [PHP-MarkdownExtra](http://michelf.ca/projects/php-markdown/extra/) parser by Michel Fortin is used.

### Cache

[](#cache)

By default, caching is disabled. Set `cache_enabled` to `true` within `config/maglmarkdown.local.php` to enable the caching. Caching could be very helpful if you have large markdown files/texts or if you're using an Adapter that relies on third-party APIs that either are rate limited or take a long time to render.

A simple filesystem cache is configured by default, but feel free to configure your own adapter.

### Adding own parsers

[](#adding-own-parsers)

It is possible to add your own parser implementation.
All you have to do, is to write a class that implements the `MaglMarkdown\Adapter\MarkdownAdapterInterface` interface and make it available through the service manager.
After that override the alias `MaglMarkdown\MarkdownAdapter`to point to your custom adapter.
MaglMarkdown will then use this class to transform the Markdown.

```
array(
	'aliases' => array(
		'MaglMarkdown\MarkdownAdapter' => 'Your\Own\MarkdownAdapter', //needs to implement MaglMarkdown\Adapter\MarkdownAdapterInterface
	),
)
```

Events
------

[](#events)

The markdown service triggers two events you can listen to:

- `markdown.render.pre` before rendering (with the markdown text as parameter)
- `markdown.render.post` after rendering (with the rendered markdown as parameter)

These events are currently used for the integrated caching feature only, but do whatever you like with these events.

Contributors
------------

[](#contributors)

MaglMarkdown is developed by Matthias Glaub and [contributors](https://github.com/maglnet/MaglMarkdown/graphs/contributors).

License
-------

[](#license)

MaglMarkdown is licensed under the MIT license.
See the included LICENSE file.

Based on PHP Markdown Lib
Copyright (c) 2004-2013 Michel Fortin

All rights reserved.

Based on parsedown
Copyright (c) 2013 Emanuil Rusev

All rights reserved.

Based on The PHP League's Common Mark implementation
Copyright (c) 2014, Colin O'Dell

All rights reserved.

Based on Markdown
Copyright (c) 2003-2005 John Gruber

All rights reserved.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 87% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~170 days

Recently: every ~425 days

Total

18

Last Release

1575d ago

PHP version history (3 changes)1.0.0PHP &gt;=5.3.0

1.5.0PHP ^5.3 || ^7.0

1.7.0PHP ^7.3 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed8ff51781adb3e444537560551a30438894fe5c3d427a8e0574ba1ed81088f5?d=identicon)[maglnet](/maintainers/maglnet)

---

Top Contributors

[![maglnet](https://avatars.githubusercontent.com/u/4430279?v=4)](https://github.com/maglnet "maglnet (127 commits)")[![thomasvargiu](https://avatars.githubusercontent.com/u/732012?v=4)](https://github.com/thomasvargiu "thomasvargiu (11 commits)")[![Koen1999](https://avatars.githubusercontent.com/u/32361020?v=4)](https://github.com/Koen1999 "Koen1999 (5 commits)")[![mamuz](https://avatars.githubusercontent.com/u/4173317?v=4)](https://github.com/mamuz "mamuz (3 commits)")

---

Tags

markdowngfmzf2Zend Frameworkparsedowngithub flavoured markdown

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maglnet-magl-markdown/health.svg)

```
[![Health](https://phpackages.com/badges/maglnet-magl-markdown/health.svg)](https://phpackages.com/packages/maglnet-magl-markdown)
```

###  Alternatives

[magento/community-edition

Magento 2 (Open Source)

12.1k52.1k10](/packages/magento-community-edition)[wheelpros/fitment-platform-api

Magento 2 (Open Source)

12.1k1.2k](/packages/wheelpros-fitment-platform-api)[erusev/parsedown-extra

An extension of Parsedown that adds support for Markdown Extra.

84314.8M192](/packages/erusev-parsedown-extra)[benjaminhoegh/parsedown-extended

An extension for Parsedown.

5022.6k1](/packages/benjaminhoegh-parsedown-extended)[slm/locale

Automatic detection of locales for Laminas

68264.6k4](/packages/slm-locale)[tovic/parsedown-extra-plugin

Configurable Markdown to HTML converter with Parsedown Extra.

5933.7k](/packages/tovic-parsedown-extra-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
