承接 sasab/react-bridge 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

sasab/react-bridge

Composer 安装命令:

composer require sasab/react-bridge

包简介

A small library small library that helps you make hybrid by integrating React.js into full stack PHP frameworks

README 文档

README

A small library that helps you make hybrid apps by integrating React.js into full stack PHP frameworks.

Inspired by react-rails gem

Getting started

All you need to do to integrate React into your favorite full stack MVC project is:

  1. npm install react or yarn add react

  2. composer require sasab/react-bridge

  3. Call the react_component or rc function somewhere in your views

  4. Finally, add the generated file(s) to your bundle or directly into your html via the script tag

If you are a Laravel user you can start using it out of the box, it uses Laravel's folder structure by default.

The "bundling" react.js file will be generated in /resources/assets/js and it will look for your React component files in the /resources/assets/js/components folder by default.

This function will detect the environment of your app from the .env file, if it is in production it will just return the <div id='my-component' data-props='{"foo":"bar"}'> file required by React. If it is in development it will write/append to the react.js file.

You can override the defaults by either using the .env file or providing the overrides as the third param to the react_component function.

    // Data provided from the server that will be passed as props to your component
    $props = ['foo' => 'bar'];

    // Default options
    <?= react_component('my-component', $props, [
        'ref' => false,
        'component' => null,
        'path' => '/resources/assets/js',
        'folder' => 'components',
        'filename' => 'react'    
    ]) ?>
    
    // or in Laravel's blade

    {!! react_component('my-laravel-component', ['foo' => 'bar']) !!}

.env:

REACT_BRIDGE_ENV=
REACT_BRIDGE_PATH=
REACT_BRIDGE_FOLDER=
REACT_BRIDGE_FILENAME=

Options

  1. ref - if you set it to true your component will have have a reference on the global window object window._components.MyComponent

  2. component - by default the first parameter to the react_component function represents the html id attribute which will be turned into the StudlyCase name of your component, and the function will look into the root of the ../components/ folder for your actual React.jsx component file.

    If you want to provide a custom name or a custom path or both you can provide it as this parameter e.g.:

    react_component('my-component', $data, ['component' => 'Articles/Comments/SingleComment']);

    Dot-notation is also supported so you can write it like this as well:

    react_component('my-component', $data, ['component' => 'Articles.Comments.SingleComment']);

    From v1.1 first parameter can be an array, so you can provide the id and the custom component as a list: :

        react_component(['my-component', 'Articles.Comments.SingleComment'], $data);
  3. path - base path where your bundling file(s) will be generated

  4. folder - folder name inside the path where your React.jsx components will be located

  5. filename - name of your bundling file(s)

Conventions

The first parameter to the react_component expects a slug that will be the id of the element which, as previously noted, will be turned into the StudlyCase name of the component, e.g.:

react_component('my-component');

If the name of the component is actually a folder the function will look for a container component inside of the folder /MyComponent/MyComponentContainer. You can read more about this React pattern here

sasab/react-bridge 适用场景与选型建议

sasab/react-bridge 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 5, 最近一次更新时间为 2018 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「php」 「library」 「mvc」 「cakephp」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 sasab/react-bridge 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 sasab/react-bridge 我们能提供哪些服务?
定制开发 / 二次开发

基于 sasab/react-bridge 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-11-13