Symfony 5 bundle to easily create dynamic subpages with Markdown. Useful for help sections and wikis.

Last update: Apr 26, 2022

MarkdownWikiBundle

This bundle allows you to create rich subpages in a Symfony project using Markdown. Pages are stored in a file cache and sourced from an external directory, for example a Git submodule.

You can use this bundle to create help sections, information wikis or any other type of sub page, that is not supposed to be hardcoded into your Symfony codebase.

Features

  • Pages sourced from Markdown files
  • Page meta stored in separate YAML files
  • Multi-language support without constraints for locale codes
  • Custom implementations for parsing, storing and fetching pages

Requirements

  • Symfony 5.3+
  • PHP 8

Installation

composer require gigadrive/markdown-wiki-bundle

Configuration

This bundle is configured using standard Symfony bundle configuration.

# config/packages/markdown_wiki_bundle.yaml
markdown_wiki_bundle:
    source_directory: "%kernel.project_dir%/example-wiki/pages/"
  • source_directory defines a path to the directory holding your source files. These are the files that make up the content and data of your wiki. For best practice, use a Git submodule.

Usage

Once you have installed and configured the bundle, you need to create a file structure for your Markdown files. You can find an example wiki for help here.

The file structure within your wiki directory is held simple.

  • Every folder represents a level of your page's path.
  • Every folder for a page needs to contain two files, one called meta.yaml and one called content.md. If you wish to support multiple languages, name these files depending on your language code. For example for an English page, call them en.md and en.yaml
  • meta.yaml files need to contain the following keys: title The page's title description The page's description Any other keys will be passed on as "custom attributes". If you need any other data for a page, save it here.

Example: If you want to create a page with the path /account/creation, you would need a folder with the path /account/creation. In that folder, you would create a file named meta.yaml and a file named content.md. The first contains meta data about your page, the second contains your actual page content.

Serving pages

You can find an example Controller to serve pages here.

Customizing the parser

MarkdownWikiBundle is built using Parsedown, a free and open-source library to parse Markdown with PHP. This bundle registers Parsedown as a service (MarkdownWikiParser) and uses it for parsing. To overwrite parsing behavior, do the following:

First, create your own implementation of the parser:

namespace App\Service;

use Gigadrive\Bundle\MarkdownWikiBundle\Service\MarkdownWikiParser;

class ExampleParser extends MarkdownWikiParser {
    // TODO: Extend Parsedown
}

Now you have a class that extends Parsedown. Refer to Parsedown's documentation to extend parsing behavior in this new service. Once you are done, register your new parser by overwriting it in the Symfony container:

# config/services.yaml
services:
    app.parser:
        class: App\Service\ExampleParser

    markdownwiki.parser:
        alias: app.parser

Customizing the storage

By default, pages are cached in the Symfony file cache. This behavior can be overwritten using the MarkdownWikiStorageInterface. With this interface, you can create your own storage behavior and save cached pages in Redis, Doctrine or wherever you need.

To ensure that the bundle uses your storage and not the default one, the markdownwiki.storage container key needs to be overwritten:

# config/services.yaml
services:
    markdownwiki.storage.example:
        class: App\Service\YourStorageImplementation

    markdownwiki.storage:
        alias: markdownwiki.storage.example

Example Wiki

This bundle was created for the MCSkinHistory help section. You can find the source of it here to help you understand the intended structure for a wiki like this.

Rebuilding the caches

Whenever there is an update to the wiki pages, the internal caches of the bundle need to be rebuilt. This can be done by running the following console command, which comes with this bundle:

php bin/console wiki:rebuild-storage-cache

Caches can also be rebuilt programatically through the MarkdownWikiStorageService:

use Gigadrive\Bundle\MarkdownWikiBundle\Service\MarkdownWikiStorageService;

class ExampleService {
    public function __construct(
        protected MarkdownWikiStorageService $storageService
    ) {
    }

    public function rebuildCaches() {
        $this->storageService->rebuildStorageCache();
    }
}

Testing

This bundle uses PHPUnit as a testing framework.

When developing for this bundle, use the following commands to test its functionality:

git submodule update --init --recursive
composer install
php ./vendor/bin/phpunit

Copyright and License

This program was developed by Mehdi Baaboura and published by Gigadrive UG under the MIT License. For more information click here.

GitHub

https://github.com/Gigadrive/MarkdownWikiBundle
You might also like...

markdown wiki/blog

markdown wiki/blog

Kwiki markdown wiki/blog Usage Place your markdown files in the /wiki directory. Categories are directories and subcategories are subdirectories. If y

May 29, 2022

Rendering markdown from PHP code

JBZoo / Markdown Installing composer require jbzoo/markdown Usage Rendering Table ?php declare(strict_types=1); use JBZoo\Markdown\Table; echo (new

Dec 26, 2021

Gruik ! An open-source markdown note-taking web app. [ABANDONED PROJECT]

What is Gruik ? It's a free & open-source note-taking service. A space where you can store notes, tutorials, code snippets... by writing them in markd

Mar 31, 2022

PHP Markdown & Extra

PHP Markdown & Extra An updated and stripped version of the original PHP Markdown by Michel Fortin. Works quite well with PSR-0 autoloaders and is Com

Jan 18, 2022

A simple regex-based Markdown parser in PHP

Slimdown A simple regex-based Markdown parser in PHP. Supports the following elements (and can be extended via Slimdown::add_rule()): Headers Links Bo

Jul 27, 2022

Docbook Tool for static documentation generation from Markdown files

Roave Docbook Tool Static HTML and PDF generator tool for generating documentation from Markdown files. Generates a deployable HTML file from Markdown

Aug 1, 2022

PHP based Markdown documentation viewer

PHP based viewer for Markdown files, to view them with fenced code highlighting and navigation.

Mar 31, 2022

Parser for Markdown and Markdown Extra derived from the original Markdown.pl by John Gruber.

PHP Markdown PHP Markdown Lib 1.9.0 - 1 Dec 2019 by Michel Fortin https://michelf.ca/ based on Markdown by John Gruber https://daringfireball.net/ Int

Aug 5, 2022

Parser for Markdown and Markdown Extra derived from the original Markdown.pl by John Gruber.

PHP Markdown PHP Markdown Lib 1.9.0 - 1 Dec 2019 by Michel Fortin https://michelf.ca/ based on Markdown by John Gruber https://daringfireball.net/ Int

Aug 5, 2022

It's basically a dynamic web browser extension that can display notifications with the help of an admin-controlled dynamic API.

It's basically a dynamic web browser extension that can display notifications with the help of an admin-controlled dynamic API.

D-NOTIFIER A self controlled dynamic API based web browser extension built by Sahil Kumar How It Works? It's basically a dynamic web browser extension

Jan 6, 2022

Provides TemplateView and TwoStepView using PHP as the templating language, with support for partials, sections, and helpers.

Aura View This package provides an implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating language. It support

Apr 22, 2022

Provides TemplateView and TwoStepView using PHP as the templating language, with support for partials, sections, and helpers.

Aura View This package provides an implementation of the TemplateView and TwoStepView patterns using PHP itself as the templating language. It support

Apr 22, 2022

A Symfony Feature Flag Bundle which easily allows you to configure and use your favorite feature flag provider.

Metro Markets FF Metro Markets FF is a Feature Flag Symfony Bundle. It easily allows you to configure and use your favorite feature flag provider. Ins

May 23, 2022

Daux.io is an documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly. It helps you create great looking documentation in a developer friendly way.

Daux.io - Deprecation Notice This repository is deprecated! Daux.io has been moved to an organization, to guarantee future development and support. So

Jul 30, 2022

Daux.io is an documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly. It helps you create great looking documentation in a developer friendly way.

Daux.io Daux.io is a documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly. It help

Aug 8, 2022

This bundle aims to easily integrate & use the Froala editor in Symfony 4.4+/5.0+.

KMSFroalaEditorBundle Introduction This bundle aims to easily integrate & use the Froala editor in Symfony 4.4+/5.0+. If you want to use it with Symfo

Jul 29, 2022

A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Jul 5, 2021

Airbrake.io & Errbit integration for Symfony 3/4/5. This bundle plugs the Airbrake API client into Symfony project

AmiAirbrakeBundle Airbrake.io & Errbit integration for Symfony 3/4/5. This bundle plugs the Airbrake API client into Symfony project. Prerequisites Th

May 6, 2022

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Jul 30, 2022
Comments
  • 1. Bump symfony/framework-bundle from 5.3.10 to 5.3.15

    Bumps symfony/framework-bundle from 5.3.10 to 5.3.15.

    Release notes

    Sourced from symfony/framework-bundle's releases.

    v5.3.15

    Changelog (https://github.com/symfony/framework-bundle/compare/v5.3.14...v5.3.15)

    • no significant changes

    v5.3.14

    Changelog (https://github.com/symfony/framework-bundle/compare/v5.3.13...v5.3.14)

    • bug #44998 Allow default cache pools to be overwritten by user (Seldaek)
    • bug #44976 Avoid calling rtrim(null, '/') in AssetsInstallCommand (pavol-tk, GromNaN)

    v5.3.13

    Changelog (https://github.com/symfony/framework-bundle/compare/v5.3.12...v5.3.13)

    • bug #44682 alias cache.app.taggable to cache.app if using cache.adapter.redis_tag_aware (kbond)
    • bug #43164 Fix cache pool configuration with one adapter and one provider (fancyweb)
    • bug #44565 Use correct cookie domain in loginUser() (wouterj)
    • bug #44481 Fix loginUser() causing deprecation (wouterj)
    • bug #44427 Fix compatibility with symfony/security-core 6.x (deps=high tests) (wouterj)

    v5.3.11

    Changelog (https://github.com/symfony/framework-bundle/compare/v5.3.10...v5.3.11)

    • bug #44110 Fix default PHP attributes support in validation and serializer configuration when doctrine/annotations is not installed with PHP 8 (fancyweb)
    • bug #44108 remove FlattenExceptionNormalizer definition if serializer not available (kbond)
    • bug #44050 Fix package names (fabpot)
    • bug #43981 fix registering late resettable services (nicolas-grekas)
    Commits
    • fef224d Enable CSRF in FORM by default
    • 4437597 bug #44998 [FrameworkBundle] Allow default cache pools to be overwritten by u...
    • 67f5d9a Merge branch '4.4' into 5.3
    • a7c76d8 [FrameworkBundle] Allow default cache pools to be overwritten by user
    • 5ae3655 [FrameworkBundle] Avoid calling rtrim(null, '/') in AssetsInstallCommand
    • 589155d Merge branch '4.4' into 5.3
    • a632944 Bump license year
    • 235ee15 fix test to actually use data provider
    • f765bc6 bug #44682 [FrameworkBundle] alias cache.app.taggable to cache.app if usi...
    • 81921ff alias cache.app.taggable to cache.app if using `cache.adapter.redis_tag_a...
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    Reviewed by dependabot[bot] at 2022-02-01 01:31
  • 2. Bump symfony/http-kernel from 5.3.10 to 5.3.12

    Bumps symfony/http-kernel from 5.3.10 to 5.3.12.

    Release notes

    Sourced from symfony/http-kernel's releases.

    v5.3.12

    Changelog (https://github.com/symfony/http-kernel/compare/v5.3.11...v5.3.12)

    • no significant changes

    v5.3.11

    Changelog (https://github.com/symfony/http-kernel/compare/v5.3.10...v5.3.11)

    • bug #43501 fix ErrorException in CacheWarmerAggregate (Ahummeling)
    Commits
    • f53025c Update VERSION for 5.3.12
    • 7e7cf0c security #cve-2021-41267 [HttpKernel] Fix missing extra trusted header in sub...
    • 87baa86 Bump Symfony version to 5.3.12
    • cdccfda Update VERSION for 5.3.11
    • 7cc3b20 Merge branch '4.4' into 5.3
    • 39035d5 Never rely on dynamic properties
    • 57e54e9 Merge branch '4.4' into 5.3
    • 73636d9 Fix typos
    • 31b284c Merge branch '4.4' into 5.3
    • 2ac1ef6 bug #43501 [HttpKernel] fix ErrorException in CacheWarmerAggregate (Ahummeling)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    Reviewed by dependabot[bot] at 2022-03-16 07:50
  • 3. Bump twig/twig from 3.3.3 to 3.3.8

    Bumps twig/twig from 3.3.3 to 3.3.8.

    Changelog

    Sourced from twig/twig's changelog.

    3.3.8 (2022-02-04)

    • Fix a security issue when in a sandbox: the sort filter must require a Closure for the arrow parameter
    • Fix deprecation notice on round
    • Fix call to deprecated convertToHtml method

    3.3.7 (2022-01-03)

    • Allow more null support when Twig expects a string (for better 8.1 support)
    • Only use Commonmark extensions if markdown enabled

    3.3.6 (2022-01-03)

    • Only use Commonmark extensions if markdown enabled

    3.3.5 (2022-01-03)

    • Allow CommonMark extensions to easily be added
    • Allow null when Twig expects a string (for better 8.1 support)
    • Make some performance optimizations
    • Allow Symfony translation contract v3+

    3.3.4 (2021-11-25)

    • Bump minimum supported Symfony component versions
    • Fix a deprecated message
    Commits
    • 972d860 Prepare the 3.3.8 release
    • b265233 Merge branch '2.x' into 3.x
    • fca80b5 Bump version
    • 66baa66 Prepare the 2.14.11 release
    • 9e5ca74 Merge branch '2.x' into 3.x
    • 22b9dc3 bug #3641 Disallow non closures in sort filter when the sanbox mode is enab...
    • 2eb3308 Disallow non closures in sort filter when the sanbox mode is enabled
    • 25d410b Merge branch '2.x' into 3.x
    • e056e63 bug #3638 Fix call to deprecated "convertToHtml" method (jderusse)
    • 779fdd0 Fix call to deprecated "convertToHtml" method
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    Reviewed by dependabot[bot] at 2022-02-11 03:26
  • 4. Basic controller for handling requests and serving pages

    Add a basic controller that implements a way to handle HTTP requests and serve pages. This could also serve as a good example on how to implement pages into an existing project.

    Reviewed by Zeryther at 2021-11-14 20:34
Easily add routes to your Laravel app by creating Markdown or Blade files

Laravel Pages This package lets you create pages using Markdown or Blade without having to worry about creating routes or controllers yourself. Essent

Jul 6, 2022
Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.
Highly-extensible PHP Markdown parser which fully supports the CommonMark and GFM specs.

league/commonmark league/commonmark is a highly-extensible PHP Markdown parser created by Colin O'Dell which supports the full CommonMark spec and Git

Aug 6, 2022
A highly configurable markdown renderer and Blade component for Laravel
A highly configurable markdown renderer and Blade component for Laravel

A highly configurable markdown renderer and Blade component for Laravel This package contains: a Blade component that can render markdown a highly con

Aug 13, 2022
Generate pseudo-static pages from markdown and HTML files for Flarum

Flarum Pages Generator This is not a Flarum extension. This package provides a Flarum extender that you can use in the local extend.php to define cust

Feb 21, 2022
A super lightweight Markdown parser for PHP projects and applications.

A speedy Markdown parser for PHP applications. This is a super lightweight Markdown parser for PHP projects and applications. It has a rather verbose

May 31, 2022
Better Markdown Parser in PHP
Better Markdown Parser in PHP

Parsedown Better Markdown Parser in PHP - Demo. Features One File No Dependencies Super Fast Extensible GitHub flavored Tested in 5.3 to 7.3 Markdown

Aug 11, 2022
Convert HTML to Markdown with PHP

HTML To Markdown for PHP Library which converts HTML to Markdown for your sanity and convenience. Requires: PHP 7.2+ Lead Developer: @colinodell Origi

Aug 11, 2022
A PHP tool to generate templateable markdown documentation from the docblocks or type-hints of your codebase.

Roster Installation To install, simply require the package using composer: composer require

Sep 8, 2021
Render colored Markdown contents on console terminal
Render colored  Markdown contents on console terminal

cli-markdown Render colored markdown contents on console terminal Preview run demo by php example/demo.php Features support auto render color on termi

Jan 27, 2022
PHP Markdown Engine Support

PHP Markdown Version v1.x support all PHP version >=5.4 v2.x support all PHP version >=7.0 Cài đặt thư viện Thư viện này được cài đặt thông qua Compos

Jul 1, 2022