bravo3/spa-bundle

Symfony 2 的包,用于创建单页应用(SPA)网络应用

安装: 72

依赖者: 0

建议者: 0

安全: 0

星级: 0

关注者: 2

分支: 0

开放问题: 0

语言:JavaScript

0.1.1 2015-05-09 05:59 UTC

This package is not auto-updated.

Last update: 2024-09-28 17:06:30 UTC


README

此包使您可以将任何普通的 Symfony 2 应用程序转换为“SPA”应用程序,使第一页加载正常渲染,所有后续页面请求通过 XHR 加载。

页面内容被拆分为“块”,只有主站点布局所需的部分会被重新渲染。

此包要求您的应用程序使用 Twig 渲染,只需要对控制器进行少量修改。

class HomeController extends AbstractSpaController
{
    /**
     * @Route("/", name="home")
     * @param Request $request
     * @return Response
     */
    public function homeAction(Request $request)
    {
        // .. 
        
        // Call the AbstractSpaController#render() function to trigger the SPA engine -
        return $this->render('@MySiteBundle/Home/home.html.twig', ['param' => 'value']);
    }
}