Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Game Development with React and PHP: How Compatible Are They?
Sep 15, 2017 @ 17:43:52

The SitePoint PHP blog has posted a new tutorial from Christopher Pitt that tries to answer the question wondering if React and PHP are compatible for game development.

“I’d like to make a multiplayer, economy-based game. Something like Stardew Valley, but with none of the befriending aspects and a player-based economy.”

I started thinking about this the moment I decided to try and build a game using PHP and React. The trouble is, I knew nothing about the dynamics of multiplayer games, or how to think about and implement player-based economies. I wasn’t even sure I knew enough about React to justify using it.

I once watched a talk by dead_lugosi, where she described building a medieval game in PHP. Margaret inspired me, and that talk was one of the things that led to me writing <a href="https://www.amazon.com/dp/1484224922>a book about JS game development. I became determined to write about my experience. Perhaps others could learn from my mistakes in this case, too.

With the foundation laid, he starts in on the setup of the backend for the game: a PHP server running a server compatible with multiple websocket (React) requests. He chose Aerys for the HTTP and websocket functionality and includes the code to create the server and the packages he required. He shares some of the code to create the server and a "Hello world" endpoint the frontend will use. He then moves over to the frontend side of things, showing the packages he installed via NPM and the Laravel Mix configuration to use Webpack to bundle up the files required. He then walks through the integration of the front and back end code including the connection of the websockets.

For those that want to see the end result all together he has posted it to GitHub in a complete form for this part of the series.

tagged: react tutorial reactphp game development part1 series websocket

Link: https://www.sitepoint.com/game-development-with-reactjs-and-php-how-compatible-are-they/


Trending Topics: