定制 camspiers/reactjs-php-render 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

camspiers/reactjs-php-render

Composer 安装命令:

composer require camspiers/reactjs-php-render

包简介

React rendering from PHP

README 文档

README

This library aims to provide multiple options for rendering React from PHP.

Experimental

The API is experimental and is likely to change.

Concepts

  • Renderer (ReactJS\Renderer\RendererInterface)
  • This interface is implemented by mutiple renderers to provide different potential rendering options (HTTP Server, V8Js etc)
  • RuntimeFragmentProvider (ReactJS\RuntimeFragmentProvider\ProviderInterface)
  • This interface is implemented to provider different environment support (CommonJS, Globals etc)

Usage

Renderers can be used directly to generate either "mountable" React HTML (including checksums and ids), or to generate static markup.

The React class (ReactJS\React) can be used to generate mountable React HTML along with JavaScript that will automatically mount the browser React component into the generated server rendered markup.

Node

When using a node process, users are required to provide source file(s) in an appropriate format for node to execute, these source file(s) need include:

  • React
  • The component you are attempting to render
$node = ReactJS\ReactFactory::createUsingNode(
	'/usr/bin/nodejs',
	['bundle.js'] // bundle.js is a browserified bundle with React and TestComponent
);

echo $node->renderAutoMountingComponent('./TestComponent');

V8

When using the V8Js php extension, users are required to provide source file(s) in the appropriate format for V8 to execute, these source file(s) need include:

  • React
  • The component you are attempting to render
$v8 = ReactJS\ReactFactory::createUsingV8(
	['bundle.js'] // bundle.js is a browserified bundle with React and TestComponent
);

echo $v8->renderAutoMountingComponent('./TestComponent');

The result:

<div id="53998c3f85044">
	<span data-reactid=".fn8fq9jb40" data-react-checksum="2066486547">Some testing content</span>
</div>
<script>
	require('react').renderComponent(
		require(".\/TestComponent")(null),
		document.getElementById("53998c3f85044")
	)
</script>

Installation (with composer)

$ composer require camspiers/reactjs-php-render:dev-master

统计信息

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

GitHub 信息

  • Stars: 45
  • Watchers: 7
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-06-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固