Skip to content

Kinspire's official website, redesigned with React.

Notifications You must be signed in to change notification settings

kinspire/website-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP + React SPA

This is a template to allow for client-side React single-page applications running on top of a PHP API server. A lot of domain hosting services only offer PHP, so this is a good way to develop a React application that works well with the PHP server.

Quickstart

Setup

Install PHP 7.x, nodejs (LTS release preferred), yarn 1.x on your computer.

Development

In one terminal, run:

$ yarn start:server

In another terminal, run:

$ yarn start:client

Deploy to gh-pages branch

$ yarn deploy

Architecture

Development

  1. The PHP server listens at port 4001 for any PHP-specific requests. At the moment, this includes:
    1. /api: any API calls
    2. /custom-php: a test area for serving custom PHP
  2. Any additional custom PHP endpoints need to be manually added to src/setupProxy.js
  3. The CRA dev server is served at port 3000 for the React development build.

Build/Production

When built, the React SPA files are located under the build/ directory. Before deploying, we move all files under the server/ directory into build/, and deploy the build/ directory.

Caveats

  1. Any links to parts of the tree that are outside the React Router tree need to be <a> anchors, since we need to reload the page and not simply set the URL. This shouldn't be a problem because elements outside of the React tree should be separate anyway.

TODO

  • Customizable branch for deployment

About

Kinspire's official website, redesigned with React.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published