teameh/silex-react-renderer-provider 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

teameh/silex-react-renderer-provider

Composer 安装命令:

composer require teameh/silex-react-renderer-provider

包简介

Client and Server-side react rendering as a Silex service provider

README 文档

README

WARNING: Silex and this project are not maintained any more. Ends of life of Silex is set to June 2018.

Read more on Symfony's blog.

ReactRenderer

This provider integrates ReactRenderer in your Silex project. This lets you implement your frontend with React.js and let php do the server-side rendering, allowing the development of universal (isomorphic) applications.

See https://github.com/Limenius/ReactRenderer for full documentation on the renderer.

Usage

Basic example

$app = new Silex\Application();
$app->register(new Teameh\Silex\Services\React\ReactRendererServiceProvider(), [
    'react.serverside_rendering' => [
        // using phpexecjs: 
        'server_bundle_path' => __DIR__ . '/path/to/your/javascript/development/bundle.js'
        // or using and external render server:
        // 'socket_server_path' => 'unix://node.sock'
    ]
]);

All config options

$app = new Silex\Application();

$app->register(new Teameh\Silex\Services\React\ReactRendererServiceProvider(), [
    'react.default_rendering' => $app['debug'] ? 'client_side' : 'both',
    'react.serverside_rendering' => [
        'fail_loud' => $app['debug'],
        'trace' => $app['debug'],
        'mode' => 'phpexecjs',
        // using phpexecjs:
        'server_bundle_path' => __DIR__ . '/path/to/your/javascript/development/bundle.js',
        // or using and external render server:
        // 'socket_server_path' => 'unix://node.sock',
        'logger' => $app['monolog'],
    ]
]);

Configuration options:

react.default_rendering:      string, either 'client_side', 'server_side' or 'both'

react.serverside_rendering:
    fail_loud                   bool, defaults to $app['debug']
                                  In case of error in server-side rendering, throw exception

    trace                       bool, defaults to $app['debug']
                                  Replay every console.log message produced during server-side rendering in the
                                  JavaScript console. Note that if enabled it will throw a (harmless) React warning

    mode                        string
                                  Mode can be `"phpexecjs"` (to execute Js from PHP using PhpExecJs),
                                  or `"external"` (to rely on an external node.js server) Default is `"phpexecjs"`

    string server_bundle_path   string (Only used with mode `phpexecjs`)
                                  Location of the server bundle, that contains the concatenated javascript bundle.
                                  This bundle should contain the ReactOnRails.register() code

    socket_server_path          string (Only used with mode `external`)
                                  Location of the socket to communicate with a dummy node.js server.
                                  Socket type must be acceptable by php function stream_socket_client.
                                  Example unix://node.sock, tcp://127.0.0.1:5000
                                  More info: http://php.net/manual/en/function.stream-socket-client.php
                                  Example of node server:
                                  https://github.com/Limenius/symfony-react-sandbox/blob/master/app/Resources/node-server/server.js

    logger                      \Psr\Log\LoggerInterface
                                  Logger used for errors

Rendering can be overridden on component basis, see https://github.com/Limenius/ReactRenderer

Credits

This project is a Silex adaption of Nacho Martín's great ReactBundle.

Both ReactBundle and this provider build on top of React On Rails, and uses react-on-rails to render React components. Don't worry you don't need and won't see any Ruby when using this package.

统计信息

  • 总下载量: 34
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固