polidog/ssr-bundle

There is no license information available for the latest version (1.0.0) of this package.

A JavaScript server side rendering for Symfony

1.0.0 2017-02-22 18:16 UTC

This package is auto-updated.

Last update: 2024-11-21 20:05:49 UTC


README

Build Status Scrutinizer Code Quality

JavaScript server side rendering (SSR) bundle for Symfony.
Inspected by bearsunday/BEAR.SsrModule

Prerequisites

  • php7.1
  • V8Js (Optional)
  • Symfony3.3~

Installation

$ composer require polidog/ssr-bundle "^1.0"

Usage

Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Polidog\SsrBundle\SsrBundle(),
        // ...
    );
}

Configuration in config.yml:

polidog_ssr:
    bundle_src_path: "%kernel.root_dir%/../web/js"

Controller Annotation.

// 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'
        ];
    }
}

Using CacheBaracoa

Set Annotation cache parameter.

    /**
     * @Route("/", name="homepage")
     * @Ssr(
     *     app="index_ssr",
     *     state={"hello"},
     *     metas={"title"},
     *     cache=true
     * )
     */