merophp/json-view

JSON view plugin for merophp/view-engine

0.1-alpha 2021-12-22 17:24 UTC

This package is not auto-updated.

Last update: 2024-11-21 23:36:54 UTC


README

JSON view plugin for merophp/view-engine.

Installation

Via composer:

composer require merophp/json-view

Basic Usage

require_once 'vendor/autoload.php';

use Merophp\JsonViewPlugin\JsonView;

use Merophp\ViewEngine\ViewEngine;
use Merophp\ViewEngine\ViewPlugin\Collection\ViewPluginCollection;
use Merophp\ViewEngine\ViewPlugin\Provider\ViewPluginProvider;
use Merophp\ViewEngine\ViewPlugin\ViewPlugin;

$collection = new ViewPluginCollection();
$collection->add(
    new ViewPlugin(JsonView::class),
]);

$provider = new ViewPluginProvider($collection);

$viewEngine = new ViewEngine($provider);

$view = $viewEngine->initializeView();
$view->json(['foo'=>'bar');
echo $viewEngine->renderView($view);