Game Development with ReactJS and PHP: How Compatible Are They? — SitePoint

  • I added my recent work with PHP preprocessors to make things cleaner, and made the first couple of endpoints:
    $host = new 8080);

    $host-use($router = = = process = process is from config.pre

    I decided to use Aerys for the HTTP and Web Socket portions of the application.

  • Finally I added pre/short-closures, both to handle the custom syntax in config.pre and the short closures I planned on using after…
    Then I set about creating routes files:
    use Aerys\Router;
    use App\Action\HomeAction;

    return (Router $router) = {
    $router-route(
    “GET”, “/”, new HomeAction
    );
    };

    This is from routes/web.

  • Finally, I created two (similar) actions:
    namespace App\Action;

    use Aerys\Request;
    use Aerys\Response;

    class HomeAction
    {
    public function __invoke(Request $request,
    Response $response)
    {
    $response-end(“hello world”);
    }
    }

    This is from final touch was to add shortcut scripts, to launch dev and prod versions of the Aerys server:
    “scripts”: {
    “dev”: “vendor/bin/aerys -d -c loader.php”,
    “prod”: “vendor/bin/aerys -c loader.php”
    },
    “config”: {
    “process-timeout”: 0
    },

    This is from composer.json

    With all of this done, I could spin up a new server, and visit http://127.0.0.1:8080 just by typing:
    composer dev

    Setting Up The Front-end
    “Ok, now that I’ve got the PHP side of things relatively stable; how am I going to build the ReactJS files?

  • I noticed Mix liked to create a manifest file, so I made a helper function to query it:
    use Amp\Coroutine;

    function mix($path) {
    $generator = () = {
    $manifest = yield $manifest = json_decode($manifest, true);

    if (isset($manifest[$path])) {
    return $manifest[$path];
    }

    throw new Exception(“{$path} not found”);
    };

    return new is from helpers.pre

    Aerys knew how to handle promises when they came in the form of $val = yield $promise, so I used Amp’s Promise implementation.

  • I found this relatively straightforward, with a new class:
    namespace App\Socket;

    use Aerys\Request;
    use Aerys\Response;
    use Aerys\Websocket;
    use Aerys\Websocket\Endpoint;
    use GameSocket implements Websocket
    {
    private $endpoint;
    private $connections = [];

    public function onStart(Endpoint $endpoint)
    {
    $this-endpoint = $endpoint;
    }

    public function onHandshake(Request $request,
    Response $response)
    {
    $origin = if ($origin !

Chris bootstraps a basic Stardew-Valley-like game in this game development with PHP post, using an async server, preprocessors, and ReactJS!
Continue reading “Game Development with ReactJS and PHP: How Compatible Are They? — SitePoint”

How to Setup a React Environment Using Webpack and Babel

  • More and more devs are using React, a Facebook and community developed JavaScript library, to craft the kinds of data-heavy, auto-uploading web apps that are used for things like making live social streams populate and render seamlessly.
  • One downside of React is that it has a notoriously steep learning curve for new developers.

More and more devs are using React, a Facebook and community developed JavaScript library, to craft the kinds of data-heavy, auto-uploading web apps that are used for things like making live social streams populate and render seamlessly. Featuring a multitude of native-use advantages, its use has grown markedly over the past four years, finding favor among companies like Airbnb, SeatGeek, and Netflix.
Continue reading “How to Setup a React Environment Using Webpack and Babel”

Game Development with ReactJS and PHP: How Compatible Are They? — SitePoint

Game Development with #ReactJS and PHP: How Compatible Are They?

  • I added my recent work with PHP preprocessors to make things cleaner, and made the first couple of endpoints:
    $host = new 8080);

    $host-use($router = = = process = process is from config.pre

    I decided to use Aerys for the HTTP and Web Socket portions of the application.

  • Finally I added pre/short-closures, both to handle the custom syntax in config.pre and the short closures I planned on using after…
    Then I set about creating routes files:
    use Aerys\Router;
    use App\Action\HomeAction;

    return (Router $router) = {
    $router-route(
    “GET”, “/”, new HomeAction
    );
    };

    This is from routes/web.

  • Finally, I created two (similar) actions:
    namespace App\Action;

    use Aerys\Request;
    use Aerys\Response;

    class HomeAction
    {
    public function __invoke(Request $request,
    Response $response)
    {
    $response-end(“hello world”);
    }
    }

    This is from final touch was to add shortcut scripts, to launch dev and prod versions of the Aerys server:
    “scripts”: {
    “dev”: “vendor/bin/aerys -d -c loader.php”,
    “prod”: “vendor/bin/aerys -c loader.php”
    },
    “config”: {
    “process-timeout”: 0
    },

    This is from composer.json

    With all of this done, I could spin up a new server, and visit http://127.0.0.1:8080 just by typing:
    composer dev

    Setting Up The Front-end
    “Ok, now that I’ve got the PHP side of things relatively stable; how am I going to build the ReactJS files?

  • I noticed Mix liked to create a manifest file, so I made a helper function to query it:
    use Amp\Coroutine;

    function mix($path) {
    $generator = () = {
    $manifest = yield $manifest = json_decode($manifest, true);

    if (isset($manifest[$path])) {
    return $manifest[$path];
    }

    throw new Exception(“{$path} not found”);
    };

    return new is from helpers.pre

    Aerys knew how to handle promises when they came in the form of $val = yield $promise, so I used Amp’s Promise implementation.

  • I found this relatively straightforward, with a new class:
    namespace App\Socket;

    use Aerys\Request;
    use Aerys\Response;
    use Aerys\Websocket;
    use Aerys\Websocket\Endpoint;
    use GameSocket implements Websocket
    {
    private $endpoint;
    private $connections = [];

    public function onStart(Endpoint $endpoint)
    {
    $this-endpoint = $endpoint;
    }

    public function onHandshake(Request $request,
    Response $response)
    {
    $origin = if ($origin !

Chris bootstraps a basic Stardew-Valley-like game in this game development with PHP post, using an async server, preprocessors, and ReactJS!
Continue reading “Game Development with ReactJS and PHP: How Compatible Are They? — SitePoint”

Day 70 First React Native App – Jon Ramer – Medium

Day 70 First React Native App  #webdevelopment #projectmanagement #reactjs #reactjs

  • Day 70 First React Native AppFirst React-Native App CompleteDay 70 is in the books!
  • Today I spent the entire day finishing up a React-Native tutorial that walked through how to make a basic app.
  • Pretty basic stuff, but I definitely learned a ton about how React manages components, state, etc…I still have lots of questions about React-Native, but I think I know enough at this point to start trying to convert my Simon game into an app that can run natively on IOS.
  • That’s my MVP to get it running on IOS where I can demo the app during the presentation.Upcoming ChallengesI mentioned in my last post that styles were going to be difficult in React.
  • Apart from the CSS challenge I don’t “think” there is any reason why I shouldn’t be able to get everything working by Thursday or maybe even sooner if I have some luck.TomorrowI’m going to create the boiler plate for my Simon app tomorrow and start migrating things over.

Day 70 is in the books! Today I spent the entire day finishing up a React-Native tutorial that walked through how to make a basic app. I’m starting to get a much better understanding of how things…
Continue reading “Day 70 First React Native App – Jon Ramer – Medium”

How to Structure Your React Project

How to Structure Your React Project @dceddia  #Reactjs #Javascript #Webdev

  • If it gets too unwieldy in one file, make a directory and put the area-specific API files under there – like , , etc. – All your Presentational (aka Dumb) components go here.
  • I don’t have to think very hard about where to find a component, or where to put a new file.
  • It’s amazing how much time you can save when the only decision you have to make at the time you create a file is whether it’s a presentational or container component.
  • And then change the scripts to include it:

    If your current level of comfort with React leads you to read articles about how to best organize your project, you probably do not need Redux yet.

  • When you add Redux to your project, start off with something like this:

    If you hate having to jump between files to create an action, check out the Ducks pattern where a reducer + related actions + types are all contained in a single file.

One of many ways to organize the files in a React project.
Continue reading “How to Structure Your React Project”

Make things that matter, together.

  • We believe everyone deserves to work on products that will be used, enjoyed, and loved – products that matter.
  • Truly excellent products are a team effort.
  • It’s our mission to help product leaders across the globe cultivate these values in their organizations, and we’ve adopted them as well.
  • With productboard, every team can make things that matter – together.

Meet the team behind productboard and find out why we do what we do and how we do the magic.

Continue reading “Make things that matter, together.”

React, Reselect and Redux – Dan Parker – Medium

React, Reselect and Redux  #redux #react #reselect #reactjs

  • It gets the state object and returns whatever state.foo.bar is.Now for ReselectReselect is a memoized selector function, composed of selectors, that returns something you want in your component’s props.import { createSelector } from ‘reselect’// selectorconst getBar = (state) = state.foo.bar// reselect functionexport const getBarState = createSelector( [ getBar ], (bar) = bar)I know that syntax looks funny at first, but here’s what happens.
  • Standard set-up, only we have our selector function getBarState(state) rather than state.foo.barWe passed our state into getBarStategetBarState calls getBar with state as the argument.getBar goes into our state object and returns bar.We use that return value in our Reselect function.Reselect handles the memoization.In Redux, whenever an action is called anywhere in the application, all mounted connected components call their mapStateToProps function.
  • all while being properly memoized.In order to properly memoize a selectorFunction for reusability, it can not be written in the same way…and your mapStateToProps must also change if it is to properly memoize.You need to create a new instance of your selector function every time it is needed for proper memoization on multiple components.To do this, change your selectorFunction to be an anonymous function, that returns a selectorFunctionimport { createSelector } from ‘reselect’// I am a selector, I need no special treatment to be properly // memoized across multiple instances// I have am now passing props so I can find a specific barconst getBar = (state, props) = { const id = props.id const barById = state.foo.bar.find((item,i) = item.id === id) return barById}// This no longer will work if it is needed in multiple places//export const getBarState = createSelector(// [ getBar ],// (bar) = bar//)// This is proper if it is needed in multiple instancesexport const makeGetBarState = () = createSelector( [ getBar ], (bar) = bar)Now when I call makeGetBarState I get a new instance of a createSelector function.To use this in my component I have to change things there as well.import React from ‘react’import { connect } from ‘react-redux’import { makeGetBarState } from ‘.
  • /selectors’// remember, mapStateToProps can have the component’s// props as the second argument// but now we need to modify this method to allow for a new// instance of our makeGetBarState function, which returns a // memoized selector const makeMapStateToProps = () = { const getBarState = makeGetBarState() const mapStateToProps = (state, props) = { return { bar: getBarState(state, props) } } return mapStateToProps}class Thing extends React.Component { …}export default need to change the standard mapStateToProps to be an anonymous function, that returns a mapStateToProps function…hence makeMapStateToPropsIn the makeMapStateToProps, I create a new instance of my selector function with the const getBarState = makeGetBarState()Now getBarState is a selector function, independent of any other selector function, and it will properly memoize across multiple mounted connected components.Clean it upWe all like short and sweet…right?
  • /selectors’const makeMapStateToProps = () = { const getBarState = makeGetBarState() return (state, props) = getBarState(state, props)}class Thing extends React.Component { …}export default has some cool features.

React is awesome. Redux is awesome, Reselect is awesome. It can be tricky to get all three to play nice together. I will try and explain, in detail, how they work together. If you have no knowledge…
Continue reading “React, Reselect and Redux – Dan Parker – Medium”