This site is built with Viewi itself. It is experimental and still in development. If you see any bugs please do not hesitate and open an issue or DM me on Twitter.



There are two types of configuration in View: renderer or the backend side. And the public side.

Let’s take a look at the Viewi config for renderer:

return [
        PageEngine::SOURCE_DIR => __DIR__ . '/Components',
        PageEngine::SERVER_BUILD_DIR => __DIR__ . '/build',
        PageEngine::PUBLIC_ROOT_DIR => __DIR__ . '/../public',
        PageEngine::PUBLIC_BUILD_DIR => '/viewi-build',
        PageEngine::DEV_MODE => true,
        PageEngine::RETURN_OUTPUT => true,
        PageEngine::COMBINE_JS => false,
        PageEngine::MINIFY => false


PageEngine::SOURCE_DIR Path to your components
PageEngine::SERVER_BUILD_DIR Location of the compiled components. Each build will recreate the content of this folder.
PageEngine::PUBLIC_ROOT_DIR Location of the public folder of your application. (It’s where you are keeping all your css, js, images). Publicly visible folder.
PageEngine::PUBLIC_BUILD_DIR Location of the compiled component for the frontend side. Recreated each build.
PageEngine::DEV_MODE If true, all components will be compiled each time you render something the first time in life scope (during a request). 

true if you want to render into a variable, otherwise - echo output.

Recommended to use true.

PageEngine::COMBINE_JS true if you want to combine app core js, components bundle js and metadata files into the single one.
PageEngine::MINIFY true if you want to include a minified version of the js file (if exists only).

Let’s take a look at the public config:

return [
    'baseUrl' => '',
    'google' => [
        'clientId' => 'clientid'
    'paddle' => [
        'vendor' => 7777,
        'product' => 7777,
        'localhost' => true

Essentially it can be anything you need. And you can use it inside of your components.

Caution: All values of public config will be exposed to the browser. Don’t put your secrets in it.

Once you have your cong files, just use it like this:

use Viewi\App;
$config = require 'config.php';
$publicConfig = require 'publicConfig.php';
// It is important to include routes before. We will get back to it later.
include __DIR__ . '/routes.php'; 
App::init($config, $publicConfig);

The $publicConfig is an optional parameter:

App::init(array $config, ?array $publicConfig = null)

To use it inside of your component just inject Viewi\Common\ConfigService:

class MyPage extends BaseComponent
    // ...
    function __init(
        ConfigService $configService
    ) {
        $config = $configService->getConfig();
        if ($config !== null) {
            $this->googleClientId = $config['google']['clientId'];
            $this->paddleVendor = $config['paddle']['vendor'];
            $this->paddleProduct = $config['paddle']['product'];
            $this->paddleLocalhost = $config['paddle']['localhost'];
        // ...

And that’s it.