PHPackages                             asm/markdown-content-bundle - 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. asm/markdown-content-bundle

ActiveSymfony-bundle

asm/markdown-content-bundle
===========================

Symfony2 bundle for static markdown-file content management

v0.4(12y ago)21601[3 issues](https://github.com/maschmann/MarkdownContentBundle/issues)MITPHPPHP &gt;=5.3.0

Since Jan 28Pushed 10y ago2 watchersCompare

[ Source](https://github.com/maschmann/MarkdownContentBundle)[ Packagist](https://packagist.org/packages/asm/markdown-content-bundle)[ Docs](https://github.com/maschmann/MarkdownContentBundle)[ RSS](/packages/asm-markdown-content-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (12)Versions (8)Used By (0)

MarkdownContentBundle
=====================

[](#markdowncontentbundle)

Basic idea behind the project was to be able to easily provide, provision and version content without a database backend. Also quite tempting: The markdown syntax.

[![Build Status](https://camo.githubusercontent.com/f89423ba9ff516fd8d0b5e23a7bf19379995949094e0552e166bd09a85c517d1/68747470733a2f2f7472617669732d63692e6f72672f6d617363686d616e6e2f4d61726b646f776e436f6e74656e7442756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/maschmann/MarkdownContentBundle) [![Latest Stable Version](https://camo.githubusercontent.com/03486a337378625585f2811470d5d64664f49066cebe58efd08102b575880b1c/68747470733a2f2f706f7365722e707567782e6f72672f61736d2f6d61726b646f776e2d636f6e74656e742d62756e646c652f762f737461626c652e706e67)](https://packagist.org/packages/asm/markdown-content-bundle) [![Total Downloads](https://camo.githubusercontent.com/2ac35655095667cc675cea960e813a305611652ba46bf2867e56a91a1f48c449/68747470733a2f2f706f7365722e707567782e6f72672f61736d2f6d61726b646f776e2d636f6e74656e742d62756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/asm/markdown-content-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c8096db8529b0e76a17448436f1b5710470818673c9c8129557131c547576d28/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617363686d616e6e2f4d61726b646f776e436f6e74656e7442756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/maschmann/MarkdownContentBundle/?branch=master)[![phpci build status](https://camo.githubusercontent.com/457aaf64d9ec54c96b9e1b6a737745b29bd1fcf756ba9071aa6fe161b6921e70/687474703a2f2f70687063692e6272306b656e2e64652f6275696c642d7374617475732f696d6167652f32)](http://phpci.br0ken.de)

What does it do?
----------------

[](#what-does-it-do)

You can configure following things:

- Content directory
- Markdown parser ([php-markdown](http://michelf.ca/projects/php-markdown/ "php-markdown") or [parsedown](http://parsedown.org "parsedown"))
- Type of loader for the files (at the moment only file-loader)
- And the prefix for your content routes

All URLs are dynamically generated and support subdirectories without limitations. MarkdowncontentBundle also supports translations! If you put your directory structure into a locale directory like `content/en_US/mycoolfile.md` it will be loaded either when using w3c urls with locale or if locale is set in your kernel. If you want locale urls, please enable the config directive.

Basics
------

[](#basics)

Some things you need to know!

### Configuration

[](#configuration)

You can set following things in your app/config.yml:

```
asm_markdown_content:
    content_directory: 'app/Resources/markdown'
    content_loader:    'file-loader'
    route_prefix:      'content'
    markdown_provider: 'php-markdown'
    #locale_url:        false

```

### Expansion

[](#expansion)

If you want, you can easily add new markdown parsers or content loaders, even hooks. For each type there's an interface you can build a tagged service upon:

#### Loaders

[](#loaders)

Asm\\MarkdownContentBundle\\Content\\ContentLoaderInterface

```
asm_markdown_content.content_file_loader:
class: 'Asm\MarkdownContentBundle\Content\ContentFileLoader'
arguments:
    - '%kernel.root_dir%'
    - '%asm_markdown_content.content_directory%'
    - '%asm_markdown_content.content_path_depth%'
tags:
    - { name: asm_markdown_content.content_loader, alias: file-loader }

```

#### Parsers

[](#parsers)

Asm\\MarkdownContentBundle\\Parser\\ParserInterface

```
asm_markdown_content.parsedown_parser:
    class: 'Asm\MarkdownContentBundle\Parser\ParsedownParser'
    tags:
        - { name: asm_markdown_content.parser, alias: parsedown }

```

#### Hooks

[](#hooks)

Asm\\MarkdownContentBundle\\Hook\\HookDataInterface Asm\\MarkdownContentBundle\\Hook\\HookContentInterface

```
asm_markdown_content.front_matter_content_hook:
    class: 'Asm\MarkdownContentBundle\Hook\FrontMatterContentHook'
    tags:
        - { name: asm_markdown_content.hook, alias: front_matter }

```

### Hook system

[](#hook-system)

The system is based on two events:

- pre-content conversion
- post-content conversion

For each registered hook service you have to set the type of hook in the *getType()* method. It's either 'post' or 'pre'. The hook just has one more interface method *workContent()* which receives the content array. Pre-hooks receive the file content ($content\['content'\]) as an array of lines, post hook will get the whole stuff as a HTML string, because it's already markdown-converted.

```
$content = array(
    'content' => array()|string,
    'data'    => array(),
);

```

That's also the data structure you're needed to return from *workContent()*. What you're doing with the data is completely up to you. The main difference between 'pre' and 'post' is the state of either data nodes. In 'pre', all content is still raw markdown, data is maybe already prefilled by other hooks (metadata hook e.g.). 'post' gets the already converted html string from your configured markdown parser. There you have the possibility to change some tags, add classes, whatever you want.

### Templating

[](#templating)

The base layout uses bootstrap3 via CDN and provides some base for your own designs. Just override

```
vendor/asm/markdown-content-bundle/Asm/MarkdownContentBundle/Resources/views/layout.html.twig

```

in your own Bundle(s). Have a look at the variable names! Content template:

```
vendor/asm/markdown-content-bundle/Asm/MarkdownContentBundle/Resources/views/Content/index.html.twig

```

### Meta data

[](#meta-data)

Since there is an accepted format for page meta in markdown, I've switched to front matter. The general format is

```
---
title: Awesome page title
author: me, myself and I
date: 2014/02/09
sample_data: { some: data, more: data_stuff }
---

```

This block needs to be the first thing in your markdown file, no whitespaces or newlines before, and the FrontMatterContentHook will extract the contents as YAML and provide the data within the content array. So you have the opportunity to place virtually everything additional you need witin that block. Besides that, default metadata will be placed in the root of the data array. They are the filled with blank content if not set via front matter:

```
$defaults= array(
    'title'       => '',
    'description' => '',
    'author'      => '',
    'date'        => '',
    'robots'      => '',
    'content'     => '',
    'name'        => '',
    'keywords'    => '',
);

```

The front matter block from above will result in this array:

```
$data = array(
    'title'       => 'Awesome page title',
    'author'      => 'me, myself and I',
    'date'        => '2014/02/09',
    'description' => '',
    'robots'      => '',
    'content'     => '',
    'name'        => '',
    'keywords'    => '',
    'sample_data' => array(
        'some'    => 'data',
        'more'    => 'data_stuff',
    ),
);

```

The data array is available in your TWIG template and fill the fields automatically ;-)

Exporting of static pages
-------------------------

[](#exporting-of-static-pages)

If you want to export all your markdown files as HTML, you can do so with following command:

```
app/console asm:markdown:export  -i

```

The exporter will use the configured markdown parser and if no import directory is provided, the configured one will be used by default. Your content is then rendered file by file into an equivalent folder stucture within the export directory, based on the provided templates. Keep in mind to add any css/js files to your static content directory :-)

Upcoming/planned
----------------

[](#upcomingplanned)

- precaching for markdown file search on compiler pass
- caching of markdown content
- maybe more loader types
- online editor

License
-------

[](#license)

AsmMarkdownContentBundle is licensed under the MIT license. See the [LICENSE](Resources/meta/LICENSE) for the full license text.

**Free Software, Hell Yeah!**

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~22 days

Total

4

Last Release

4417d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1ae7274ffaebc203b1541748c0e8c2918b3135bef004ff4c6c8e4d1b6fe1d0f0?d=identicon)[asm](/maintainers/asm)

---

Top Contributors

[![maschmann](https://avatars.githubusercontent.com/u/157620?v=4)](https://github.com/maschmann "maschmann (50 commits)")

---

Tags

symfony markdownsymfony markdown cms

### Embed Badge

![Health badge](/badges/asm-markdown-content-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/asm-markdown-content-bundle/health.svg)](https://phpackages.com/packages/asm-markdown-content-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)

PHPackages © 2026

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