Code Monkey home page Code Monkey logo

react's Introduction

react

Latest Stable Version Build Status StyleCI Test Coverage Code Climate

PHP wrapper to execute babel with react-jsx trasformer plugin or fallback to a PHP alternative.

Usage

First you need composer if you have not already. Then get the package with composer require nodejs-php-fallback/react then require the composer autload in your PHP file if it's not already:

<?php

use NodejsPhpFallback\React;

// Require the composer autload in your PHP file if it's not already.
// You do not need to if you use a framework with composer like Symfony, Laravel, etc.
require 'vendor/autoload.php';

$react = new React('path/to/my-react-file.jsx');

// Output to a file:
$react->write('path/to/my-js-file.js');

// Get JS contents:
$jsContents = $react->getResult();

// Output to the browser:
header('Content-type: text/javascript');
echo $react;

// You can also get react code from a string:
$react = new React('
ReactDOM.render(
    <h1>Hello world!</h1>,
    document.getElementById("main")
);
');
// Then write JS with:
$react->write('path/to/my-js-file.js');
// or get it with:
$jsContents = $react->getResult();

// Get source map contents:
$sourceMap = $react->getSourceMap();

// Get source map path:
$sourceMap = $react->getSourceMapFile();

// Pass false to the React constructor if you do not need source map:
$react = new React('path/to/my-react-file.jsx', false);

react's People

Contributors

kylekatarnls avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mrynt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.