Git Product home page Git Product logo

php-server-side-react's Introduction

PHP Server Side React with Webpack

This is an experiment to try and get the most simple possible PHP serverside rendering with React and Webpack.

Requirements

  • php ^5.3.3
  • composer ^1.2.0
  • node ^6.0.0
  • npm ^3.0.0

Getting Started

$ git clone https://github.com/inooid/php-server-side-react.git
$ cd php-server-side-react
$ composer install
$ npm install  # Install Node modules listed in ./package.json (may take a while the first time)
$ npm start    # Compile and watch for changes

# open a new terminal window
$ npm run php:start
$ open http://localhost:8000

How it works

  1. npm start compiles the /src into a build/client.js and build/server.js
  2. The index.php checks using PHPExecJS what the best runtime is that is available (node or php-v8js)
  3. The php file will locate the build/server.js and renders the components to string with the provided props.
  4. It will then print the HTML file including the initial props
  5. It will then include the build/client.js that will pick up the initial props bound to window.__REACT_INITIAL_PROPS and render the client side part, including event handlers.

php-server-side-react's People

Contributors

inooid avatar

Watchers

 avatar

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.