\ HTML5 Stock Market Simulation in PHP

Update: Source code now available

Download the source code for this application.


HTML5 WebSocket Server in PHP

In response to the several emails I have received in the last two weeks, I have decided to take the time to post the source code for my HTML5 Stock Market simulator written in PHP. I wrote a PHP implementation of HTML5 Web Sockets, and made a simple Stock Exchange simulator application out of it with HTML5 (Javascript’s Web Socket object). While I’m at it, I’ll go ahead and post a brief explanation of what I did and how things work, so check back soon if that is of any interest to you. Here’s a link to the YouTube screen cast that I posted about it. Or if you’d like, I guess you can just watch the video right here:

The Code

For those of you who have been waiting for me to post the code for this, I apologize for the delay. Download the source code and play around with this stock simulator for yourself. I was just trying out the app a few minutes ago, and I noticed that the latest version of Chrome wasn’t connecting to the PHP server for some reason. The server recognized the connection request, and even maintained the socket opened, but the browser threw some exception. I haven’t looked into it too much due to current time constraints, so someone that finds out something about it please post. The code does work just fine in Safari, though. I have not tested it in Firefox, but I’d assume it’d work fine. If not, make sure that there’s no settings that prevent websocket connections from being established. As far as Internet Explorer 9 is concerned, I haven’t tried it either, but wouldn’t be surprised if it worked with it, too.

So there you have it. There are instructions in the zip file on how to run the application. As far as extending the app, or building different apps using the server, feel free to do whatever you want with it. Although the code was written for a networking class that I took at school, the elegance and clarity of the code was not the priority. Thus, any graphics about a CS460 class, or poor code documentation can be justified for this reason.



Leave a Reply

Your email address will not be published. Required fields are marked *

*

4 thoughts on “HTML5 Stock Market Simulation in PHP

  1. Hi,
    I am very interested to learn HTML5 and javascript. I would be grateful if you could share the source code of Stock Market. I am really impressed and want to continue programming.
    CU
    /S.L

  2. Awesome work! Very nicely done. I want to implement this on my website, but i have one small problem. How do i get it to work from any other host then “localhost”. Ive tried changing $pHost in websocket.server.php and websocket.socket.php, with no success. Id just like to try this from another machine. Any suggestions? Thanks

\ Social Media

Social Media Google Plus Facebook Linked In Twitter Blogger YouTube

\ Popular Tags


\ Latest Tweets