Download the PHP package gigadrive/markdown-wiki-bundle without Composer
On this page you can find all versions of the php package gigadrive/markdown-wiki-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package markdown-wiki-bundle
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
Configuration
This bundle is configured using standard Symfony bundle configuration.
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 calledcontent.md
. If you wish to support multiple languages, name these files depending on your language code. For example for an English page, call themen.md
anden.yaml
meta.yaml
files need to contain the following keys:title
The page's titledescription
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:
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:
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:
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:
Caches can also be rebuilt programatically through the MarkdownWikiStorageService
:
Testing
This bundle uses PHPUnit as a testing framework.
When developing for this bundle, use the following commands to test its functionality:
Copyright and License
This program was developed by Mehdi Baaboura and published by Gigadrive UG under the MIT License. For more information click here.
All versions of markdown-wiki-bundle with dependencies
gigadrive/php-commons Version ^1.1
symfony/framework-bundle Version ~5.0
doctrine/annotations Version ^1.13
symfony/yaml Version ^5.3
ext-json Version *
erusev/parsedown Version ^1.7
symfony/finder Version ^5.3
symfony/cache Version ^5.3
symfony/http-kernel Version ^5.3
symfony/console Version ^5.3