merophp / json-view
merophp/view-engine 的 JSON 查看插件
0.1-alpha
2021-12-22 17:24 UTC
Requires
- php: >=7.4
- ext-json: *
- merophp/view-engine: 0.1-alpha
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2024-09-26 22:54:56 UTC
README
merophp/view-engine 的 JSON 查看插件。
安装
通过 composer
composer require merophp/json-view
基本用法
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);