Download the PHP package b-tokman/yii2-react without Composer
On this page you can find all versions of the php package b-tokman/yii2-react. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package yii2-react
Yii2-React
This is Yii2 widget that able to use ReactJS components in your Yii2 app, with options of server-side rendering.
Installation
This widget require v8js php extesion. How to setup V8Js PHP extension? Use the links below:
- On Linux
- On MacOs
- On Windows
Composer
Set the
minimum-stability
in your composer.json todev
- This widget compile react bundle from npm react and react-dom packages using browserify and uglify-js BUT since composer run scripts only for root composer.json, need to add the following lines to your composer.json:
This way composer will run browserify to create react-bundle.js and uglifyjs to minify it, each time after upgrade or install
- Then run
Composer will download yii2-react package with all dependenices, then npm will download react and react-dom npm packages and scripts will compile it.
Usage
After the installation you'll be able to use the bTokman\react\widgets\ReactRenderer
widget in your app.
componentsSourceJs
- path to your react components js filecomponent
- the name of global variable the contain your React component, you also can use namespased components by dot-notationprops
- props array that'll be passed to your componentoptions
- Array of options that you can pass to widget:
prerender
- Tells widget to render your component server-side, by default -true
tag
- The tag of the element where your component would be passed- html attributes - HTML attribute that will be added to the wrapper element of your component. Example:
'id' => 'root'
.useTranspiler
- boolean, whatever to transpile js code, using bable or not. If you dont have JSX or other specific syntax, dont use transpiler, to save some time
All your reactJs components must be in window
scope.
Example
In your view file:
Example main.js
Namespased components:
Example layout.js
All versions of yii2-react with dependencies
yiisoft/yii2 Version ~2
reactjs/react-php-v8js Version ^2.0
talyssonoc/php-babel-transpiler Version master
koala-framework/composer-extra-assets Version ~1.1