polidog / ssr-bundle
此包的最新版本(1.0.0)没有可用的许可证信息。
Symfony的JavaScript服务器端渲染
1.0.0
2017-02-22 18:16 UTC
Requires
- php: ~5.6|~7.0
- koriym/baracoa: 1.x-dev
- sabre/cache: ^1.0
- sensio/framework-extra-bundle: ~2.7|~3.0
- symfony/framework-bundle: ~2.7|~3.0
Requires (Dev)
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2024-09-21 19:45:18 UTC
README
Symfony的JavaScript服务器端渲染(SSR)包。
由bearsunday/BEAR.SsrModule审核
先决条件
- php7.1
- V8Js(可选)
- Symfony3.3~
安装
$ composer require polidog/ssr-bundle "^1.0"
使用
启用包
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Polidog\SsrBundle\SsrBundle(), // ... ); }
在config.yml中的配置
polidog_ssr:
bundle_src_path: "%kernel.root_dir%/../web/js"
控制器注解
// src/AppBundle/Controller/DefaultController.php <?php namespace AppBundle\Controller; use Polidog\SsrBundle\Annotations\Ssr; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Bundle\FrameworkBundle\Controller\Controller; class DefaultController extends Controller { /** * @Route("/", name="homepage") * @Ssr( * app="index_ssr", * state={"hello"}, * metas={"title"} * ) */ public function indexAction() { return [ 'hello' => [ 'name' => 'polidog', ], 'title' => 'polidog lab' ]; } }
使用CacheBaracoa
设置注解缓存参数。
/**
* @Route("/", name="homepage")
* @Ssr(
* app="index_ssr",
* state={"hello"},
* metas={"title"},
* cache=true
* )
*/