Custom Providers

Baun uses the idea of "providers" to abstract out most of it's implementation. This makes it easy to create your own custom providers and swap them out via the settings in config/providers.php.


Every provider implements an interface. This is important to maintain proper functionality within Baun. Every provider must implement the minimum methods defined in each interface. See the default Interfaces for more info.


A good place to start when creating a custom provider is to have a look at the default Providers.

As an example let's imagine you wanted to change the template engine from Twig to something else. You would achieve this by creating your own Template Provider. It might look something like:

<?php namespace My\CustomProviders;

use Baun\Interfaces\Theme as ThemeInterface;

class CustomTheme implements ThemeInterface {

    public function __construct($themes_path)

    public function render($template, $data = [])

    public function custom($name, $data)


You can then package your provider and make sure it is autoloaded.

Then all the user needs to do is install your package using Composer, and change the line in their config/providers.php. For example:

'contentParser' => 'Baun\Providers\ContentParser',
'router'        => 'Baun\Providers\Router',
'theme'         => 'My\CustomProviders\CustomTheme'

Default Libraries

By default the Baun providers use the following libraries:

Provider Library
contentParser PHP Markdown
events Event
router PHRoute
theme Twig