Php/Javascript to make a browser game? - php

I've been on and off intrested in making a text based browser game.
I have been turned off by the idea because of the daunting amount of things to learn.
PHP (or another sever side scripting language)
Javascript
HTML
MySql
And the fact of severs and apache..
Can I just pay for web hosting and by-pass having to set-up apache?
Also how long will it take me to learn all thoose things well enough to start work on my game?
Should I just stick with Flash and then C# for XNA?

Just install XAMPP, which is basically the lazy man's Apache/PHP/MySQL setup in 1 click. You just install it and it does all the work, nothing for you to setup nor config.
Don't let the complexity of PHP/HTML/Javascript set you off, we all hard to start somewhere. Just start with the parts you know how to make, then look around for each individual problem. Being motivated is key to learning anything, and if you have something you enjoy working on, you won't have a problem learning what you need to pull this off.

Do you have a specific game in mind?
Does it need to be multiplayer?
In the initial stages, does it require server interaction at all?
Conversely,
Are you interested in the possibility of building a working game first, and adding in features like saving high scores, multiplayer, or other server-interactions later?
Is a self-contained game like nethack or Hitchhikers a good starting place for you?
If your initial game does not require server interaction, you can build quite complex games using only HTML and JavaScript. This will reduce the number of concepts and languages you need to learn up front.
Once you have had some practice building non-trivial games in HTML and JavaScript, you can then add in features like server-integration, and learn a server-side language like PHP, Python, Perl, ASP.NET, or Ruby...
You can definitely pay for hosting, and eliminate the effort of setting up and maintaining a server yourself. A quick search will find you a number of web hosting sites to choose from.

I believe sticking with flash would make things easier, as syncing multiplayer with javascript and PHP isnt going to be easy.

It depends how complex the game you want to make is. You can easily learn some basic PHP and javascript inside of a month (like pretty much any other language), but it'll take a lifetime to master (like any other language).
I would recommend you start out small - plan to implement just a subset of your features, and take them on one at a time.
I would plan to use libraries / frameworks. For Javascript I would currently recommend JQuery because I find it easy to use, it has a large community and it's well documented. Using a library like JQuery allows you to easily ignore a lot of the browser specific details, since they deal with all that nonsense for you.
For PHP I personally use Zend Framework - this is a massive beast that isn't always the best documented, but if you start with the "Quick Start" tutorial and then only look at features as you need them, you shouldn't get overwhelmed too easily. One of the great things about Zend is that you can pick and choose what features you want to use without hassle.
With regards to servers, yes you can use a web host and bypass setting up a full server yourself very easily and cheaply. You can find local installations (eg. XAMPP) that will allow you to quickly set up a local install of Apache, PHP and MySQL to get started with.

First of all, if you're developing an MMO or want to offer multiplayer support, you're going to need to learn PHP and mySQL. In theory, you could go ASP.NET instead, but I would strongly advise against it, since Microsoft servers cost more to rent, and since PHP/mySQL is much better documented and easier for beginners to learn. If you're building a single-player game, Javascript and HTML could technically be adequate, but knowing PHP will still make your life easier, in the long run.
Although you should probably set up a LAMP stack (Linux Apache mySQL PHP) on a local network so you understand how it works, hosting your own server almost never makes sense for a production environment. You could, however, save yourself some money by developing the game on your own LAMP stack. Alternately, most shared hosts (around $80 / year) provide support for PHP and mySQL, and this would be perfectly adequate for building your game. Eventually, once you're ready to launch -- and assuming it becomes even marginally popular -- you're going to need at least a VPS, and possibly a dedicated server.
Finally, a note on Flash:
In the last few years, the popularity of mobile devices has skyrocketed, and this presents a risk for Flash games, since Apple refuses to support the plugin. If you need advanced graphics support, a more timely alternative would be HTML5. Unfortunately, this carries its own set of drawbacks: namely, since it's a long way off from official release, it's not yet universally supported, and features that are supported will vary from one browser to another. So basically, HTML5 is the future, and Flash is the past. The best option for right now? Probably Javascript; you might be surprised what JS can achieve, when properly combined with CSS, and you'll need it for AJAX functions anyway. Best of all, it's supported by virtually every device and browser.
So, in conclusion, I'm recommending that you learn HTML, CSS, PHP, mySQL and Javascript, and don't be intimidated by that variety of languages; the more you learn, the more easily you learn the rest.

Related

What are the relative advantages of various Python/PHP web frameworks (particularly for my project)?

I'm deciding on a web framework for an upcoming project, and I'd appreciate any advice. We've decided to use jQuery for the JavaScript, and are heavily leaning toward Python or PHP (more Python) for our server-side logic. I'm especially interested in web2py because of its jQuery integration.
About our project
Our project is to develop a security console for a complex
cybersecurity system operating within an organization's internal
network.
This console will be largely server-driven, as messages come in from the network and must be pushed by the server to the user.
The user will also be able to initiate security actions, the implementation for which will likely be in C++.
The interface we've planned will be relatively rich, and I want to leverage jQuery's power as much as possible.
We have some control over the browser environment we'll be running in (e.g., we don't have to worry about clients with JavaScript disabled).
Our site is likely to have only a few, long-lived client connections.
We are looking for software components with permissive licenses, though we're using some copyleft components (I see that web2py is LGPL while Django is BSD, so +1 to Django)
We have about a month to create a functional demo of our system, of which this interface is a small (but visible) part.
About us
We are two developers with about 5 years of programming experience, but little web development experience. I have several years of Python experience and a summers' worth of experience messing around with PHP. My coworker has some Python experience and has never touched PHP.
I used Django once back in 2008, and was frustrated by the file and code structure, which I found highly unintuitive. Perhaps this structure is inherent to the MVC model (I've had similar experiences with Django and CakePHP since), and I just need to bite the bullet and memorize it.
My Question
Given the information above, what are the relative advantages of the various Python/PHP web frameworks for our project? As mentioned above, I'm especially interested in web2py because of its jQuery integration, though Django's dominance is (once again) hard to ignore.
Thank you very much for your time!
Before deciding on a framework, you should first decide if you want to commit to a language you are unfamiliar with.
You said you've both got minimal PHP experience, so you have to weigh up the advantages here; Will the pros for going PHP (if any) out weigh the amount of time the developers will need to spend to retrain?
(Although depending on your background experience, PHP should be very easy to pick up.)
If you frame it like that, PHP would have to have a pretty convincing offering to give you. From what I'm seeing, specifically Django vs web2py, they both seem very close in functionality - which is good, but doesn't provide the "you must use x!" scenario you may be after.
However, If you will be bringing more people in later and feel finding people to work with web2py will be difficult, it may tip it to PHP. You said your self, Django's popularity (and BSD license) is hard to ignore, and it should make it easier to find people for later expansion.
If it were me, in your shoes, I would go with web2py. Assuming the development team will continue to be Python focused for the foreseeable future.
Python vs PHP: Python
With python, you can always write wrappers for C code so you won't have to mess with starting other processes and passing args to them. That might be useful for your security functions.
Web2py will allow you to easily write a webservice for this too, to more easily integrate the C portions with the web-site infrastructure.
If you already prefer python, I would go with that. If you need to bring on web-developers later that are trained in PHP, teach them Python. It won't take long, and I'm sure they'll appreciate it in the long run. Plus, moving from a PHP MVC framework to web2py or even django would make things easier. I've used CodeIgniter for PHP and find that web2py was so much simpler and easy to understand.
Also as for the directory structure, django is not actually true MVC -- it's MTV (model, template, view).
I find web2py's organization a little more straight-forward. But yes, either way it can seem strange at first. I would say YES, you should bite the bullet and use MVC.
In web2py, the "view" is html markup with the ability to write raw python code. The controller extracts data from the model (database), attaches any needed files (css/js etc) and the model of course simply defines the structure of the data and allows you to access it in an OO way.
Lastly, I wouldn't tip my hat in favor of web2py just because of jQuery integration. It does use it, and a some of the built-in framework stuff (like response.flash/session.flash, the LOAD function that loads a page or data from another controller) rely on jQuery, but using it in another framework only means you have to write an include statement (e.g. ).
But, the way it allows/forces you to focus on development is what takes the cake for me.
I've been using Django as part of my work for a couple years now and truly enjoy it when I can make it work. Unfortunately, and maybe it's just me, but I end up spending hours working on configuration every time I start a new server, or try to make it work in a development IDE.
It's relatively simple to start a new project and start coding. But there are all sorts of little catches that keep things from working if you deviate from the norm. Things like if you want your django project to serve from a subdirectory like example.com/django. The information is out there to make it work. But it's hard to find.
I can't tell you if web2py has those same problems or not. I only just learned about it from your question. It does look slick and simple though. I can tell you that after the hassles of getting the applications to serve properly from whatever server configuration I'm using, django is way more fun to program with than plain php. PHP frameworks may differ.
From my understanding the project not usual web application, you must need event driven program, web server in python.
Django won't help you here.You should look into Flask, Flask has inbuilt console too.http://werkzeug.pocoo.org/, you might need to use twisted, gevent,Flask jquery.
I would recommend asking about web2py on its mailing list -- you'll get lots of help and advice there. Regarding the LGPL license, note that it only applies to the framework, not your application -- you can license your application however you like, including closed source/commercial.
It sounds like you'll need some server push functionality, but if you'll really only need a few long-lived connections at a time, you might not need to bother with solutions like Twisted or gevent. If necessary, though, web2py does include this (requires Tornado, and works using WebSockets, though can be adapted to use other methods).

Creating a real time website using PHP

I'm currently creating a website using PHP and the Kohana framework. I want to site to be able to use real time (or near real time) data (e.g. for chat and real time feeds). I need it to be able to scale to thousands of concurrent users. I've done a lot of reading and still have no idea what the best method is for this.
Does anyone have any experience with StreamHub? Is it possible to use this with PHP?
Am I digging myself into a hole here and need to switch languages? I've looked at node js and nowjs, but I'm weary about coding a while site in Express (I wonder about security holes, code maintainability, lack of a good ORM). I've read about Twisted Python, but have no idea what web framework would work well on top of that, and I'd prefer not to use Nevow - maybe Django can be used well with Twisted Python? I'm just looking to be pointed in the right direction, so I don't go too far in PHP and realize I can't get the near real-time results that I need.
Thanks for the help.
I've looked at node js and nowjs, but
I'm weary about coding a while site in
Express (I wonder about security
holes, code maintainability, lack of a
good ORM).
I can personally vouch for code maintainability if you can do JavaScript. I personally find JavaScript more maintainable then PHP but that's probably due to lack of PHP experience.
ORM is not an issue as node.js favours document based databases. Document based databases and JSON go hand in hand, I find couch db and it's map/reduce system easy to use and it feels natural with json.
In terms of security holes, yes a node.js server is young and there may be holes. These are un avoidable. There are currently no known exploits and I would say it's not much more vulnerable
then IIS/apache/nginx until someone points a big flaw.
I want to site to be able to use real
time (or near real time) data (e.g.
for chat and real time feeds). I need
it to be able to scale to thousands of
concurrent users.
Scalability like that requires non-blocking IO. This requires a non-blocking IO server likes nginx or node.js (Yes blocking IO could work but you need so much more hardware).
Personally I would advice using node.js over PHP as it's easier to write non blocking IO in node. You can do it in PHP but you have to make all the right design and architecture decisions. I doubt there are any truly async non-blocking PHP frameworks.
Python's twisted / Ruby's EventMachine together with nginx, can work but I have no expertise with those. At least with node you can't accidentally call a blocking library or make use of the native blocking libraries since JavaScript has no native IO.
PHP is not the language you should be using for real-time updates of a website. PHP scripts load first before HTML (and HTML calls javascript files), so PHP cannot update your page for you. However, when used with AJAX (eg. using a jQuery function to call a PHP file to update your page in real-time), you can use PHP in this fashion.
Using jQuery and AJAX (all javascript), you can do quite a bit in terms of updating a page without reloading it. I've seen sites such as this one that demonstrate how to make a chat using jQuery.

Using PHP for medium to high-load public websites

I am planing to build a website using PHP to be hosted on the public internet with decent user load (between 1000 to 5000). I am using FreeBSD as a server and I configured Apache, PHP and MySQL from scratch.
With proper configuration, is it safe to use such a server, or should I go with some web framework? I am asking as I've heard few horrible things about PHP.
If it is safe, does PHP get too complex when the size of the site increases beyond a certain point?
I know Facebook uses PHP; are there any other big websites that use PHP?
Last, is it recommended to use some PHP framework or should I stick to plain old PHP?
PHP works fine for just about any size server. The question isn't really the programming language but the infrastructure you set up. 1000-5000 users is not very many unless they are all banging on the site at the same time. Are they doing a lot of DB queries or consuming a lot of CPU resources? If so, then you may want to look at a dedicated MySQL server for the DB queries.
I have nothing against frameworks. However, you are usually shoehorning your problem into their solution. Careful design on your part with common routines, etc., are usually just as good as a framework in my opinion. However, some people are more comfortable working within a framework because it removes some of the plumbing issues.
A lot of large sites use PHP. It may not be obvious because they hide the extension of the scripts in the URLs.
With proper configuration PHP is fine. However if youre new to php and server administration you might want to read up on configuring php as well as Apache for security. Youll also need to read specifics on configuration for performance as well but you need to have an app to test before its really worth doing that beyond some basics.
As far as using a framework or just basic PHP that depends totally on you. a framework is othing more really than a set of useful code and structure to accomplish alot of tasks. If you dont use a framework youre going to have to write code that meets similar requirements, so you might save time using a framework. Generally you are going to sacrifice performance in trade for having to design/write less code. You need to decide yourself if a framework (and which one) is right for the project.
In terms of sites that use php... There are a ton... Facebook, Yahoo Bookmarks, Daily Motion, parts of MySpace (at one time, not sure if its still the case), anything running Drupal or Wordpress... PHP is more than capable.
PHP is just a tool and choice of framework does not really makes your application secure or fast, unless you understand the principles of web security and how things works.
Facebook is good example of what php is capable of in hands of processionals. And there are plenty of websites that capable to handle 10K visitors a day on a single low end server.

Desktop software development (possibly using web technology) and cryptographic checks

OK, go easy on me as it's my first question here. ;)
I am experienced in Web Application development, but I need to design 2 different desktop applications at work. I need advice on what languages to use (I use PHP for Web Applications, I have little other experience), any frameworks that may help me accomplish this easier and any IDEs to use to make my life easier too.
My first application will essentially be an interface to an embedded or remote DB and essentially it needs to do not much more than CRUD. A fulltext search function will be necessary as will sorting of the CRUD table too. I'd like to include the possibility of hiding columns of data too, but this isn't a priority. I currently use MySQL, but am happy to use any other DB, as long as they support importing from Excel. Of course, if it supports an excel spreadsheet as the database, fantastic, but wishful thinking...
I only need to support Windows XP upwards, this won't change. Let me know if I can add anything to help answer this.
My second application is going to be more complicated, I guess. It needs to output the SHA, MD5, CRC-32, CRC-16 signatures for an entire external drive on-screen and/or into a text document of the users choice (new and append). The external drive could be Compact Flash, EEPROM, CD-ROM, DVD-ROM, SD, etc. Whereas I have an idea where to start on the first application, this one is where I need major help as I have no idea which programming language has built-in support for all the algorithms above, or the best way to go about coding it. So any and all advice will be more than welcome.
Edit: OK, so I have come across Titanium and am wondering if this is the best option out there for my 2 projects. The first one I am certain I can achieve, but the second project is going to be pretty difficult I believe, as unlike most hash calculators out there, I do not only need to check individual files for SHA/MD5/CRC-32/CRC-16, but I also need to check Compact Flash through a USB-connected Sandisk CF reader and EEPROMs through a COM or USB connection as well. I essentially need to produce the signature/hash for the entire drive, not the files on it. Any advice on this in particular would be helpful, please let me know if I am going too far off-topic by stackoverflow standards, as I can create a new question with this in.
I'm going to have to say Perl might be a good (though not necessarily the best) option for you, if you aren't one of the PHP developers who are Perl-allergic:
Perl is probably easier for a PHP developer to pick up than some statically typed compiled language that typical desktop apps are written in
Perl has libraries to interface to pretty much ANY database back-end you want, though I'm not 100% sure about using Excel as DB directly (I'm fairly confident something exists in CPAN but can't recommend anything from personal experience).
Perl has Windows GUI development - from an easier (for you) web GUI using local/embedded web server to Tk to Win32 GUI modules (StackOverflow has a couple of questions with very good references on the topic of Perl Windows GUI options).
Perl has a fairly complete set of support for MD5/SHA etc... Again CPAN is your friend.
If the only development experience you have is PHP for web, your options for quick desktop development are seriously limited.
since i don't know of any (sane) way to use PHP for desktop apps, my first thought was to reach for a framework that would let you use JavaScript and a mostly declarative UI. That would save you from most of the pain.
The best one for that would be Qt, which is supposed to let you do almost everything on QML and JavaScript. the unfortunate part is the 'almost'; since anything that escapes that would mean C++ development. The best C++ environment, for sure; but still widely different from Web work (specially PHP web work).
The other option, which I think would be best for you is Adobe AIR. I haven't really checked it; but it lets you write a 'desktop-like' app using only Flash (with or without the Flex framework) or HTML+JavaScript. When i first saw it seemed pretty much complete. For DB work i think it can use an embedded SQLite library; or access any HTTP service (which could be a local DB+PHP app exposing the CRUD methods)
You could try PHP-GTK.
It may not be the fastest, but it does work.

Starting out doing server side things - what languages and techniques to choose?

I've been doing html, css and javascript for quite a long time, mostly for my very own enjoyment. I would say I know fairly much, I've created many simple games and apps and experiments with javascript. However there is only so much that is possible to do in the browser, for any more "complete" websites I am constantly confronted with my ignorance on server side programming.
So, what do I need. I need to get my head around how to use databases and how to use some server side programming language, I guess. What is the right choice? What should I avoid?
Thanks.
PHP and MySQL have a pretty low barrier to entry (they're both free and ubiquitous). I'd start with those, since most hosts provide them for you. As an added bonus, they work really well together (and PHP isn't very hard to learn coming from a web development background).
Head First SQL is a great book for learning MySQL. All of the examples in the book are done on MySQL. The book even explains where to get it and how to install it. As for PHP, the introductory tutorial at official website is the best place to learn it.
Update: Head First PHP & MySQL is now available. I haven't read this one yet, but other books in the series and by the same author are great for learning new languages from scratch.
Download Python. Learn the Python language. Learn Object-Oriented programming.
Python includes SQLite, this makes it easier to Learn the SQL language.
Download the Django framework. This makes it easy to write server-side applications that work simply and reliably.
I would suggest PHP. Not because it's the best, most modern or cleanest language out there, but because it is easy to learn for someone coming from pure HTML.
You begin by just adding tiny bits of PHP to your regular HTML and magic happens :)
Ruby is a fantastic language and the frameworks for web stuff generally teach you some good practices. Try it. The Learn to program book uses Ruby, maybe you'd like to check it out.
I noticed in your question you mention that you've been using javascript. If you're comfortable progamming javascript, I've recently begun working with server side javascript in the form of EJScript on linux and using jscript on windows. It's been fairly painless, and the documentation has been pretty good so far on both.
If you're more interested in learning this with another technology then Django & Python or ASP.NET & C# (or IronPython) are both fairly low barrier to entry platforms available on windows, *nix, etc...
I would say that if you're comfortable working in Linux, then go for PHP and MySQL. If you aren't comfortable working in Linux, then download the free Visual Web Developer version of Visual Studio Express, and get started using that. This lets you program in VB.Net or C#, and use the .Net web development framework. It's really miles ahead of anything PHP in terms of how nice a platform it is to work on. There's also a free developer edition of SQL Server that lets you store up to 4 GB of data.
There's plenty of .Net hosts out there now too. Although, due to increased license costs, Windows hosting plans will usually cost more and give you less space/bandwidth than Linux hosting plans, you can still get enough room to play around with and deploy some apps on the web. If you develop something really cool, and outgrow what your hosting account provides, it's probably time to upgrade to a VPS, and post ads on your site to start paying the bills
I'd recommend PHP for folks who are familiar with HTML but are newish to programming. Here's why:
I'm currently an ASP.Net developer, and I think that ASP.Net abstracts waaaaay to much to make it a good first programming environment. I say learn how to generate and manipulate straight HTML with a language like PHP instead of trying to understand GridViews, etc., which have no bearing or relevance to programming in the broader sense.
I wouldn't say ASP.Net is "the Dark Path" or anything, but if you start out by learning it, you'll tend to favor the warm and insulating arms of the framework. ASP.Net is pretty much a code-generator when compared to more explicit (some would say reckless, messy, and tedious, but I'm not one of them) methods like PHP.
With PHP you'll see the effect your code has on the actual HTML when you view source. With an ASP.Net page, you'll be baffled by the amount and complexity of the HTML it spits out.
After you get your hands dirty in PHP, you can explore the pros and cons of frameworks like ASP.Net that "do a lot of the work for you".
I was exactly in your situation 3 to 4 years ago and, like some of the commentators suggest, I tried PHP because of its low barrier of entry.
That was a mistake! Oh sure I was able to achieve some things here and there, including using a contact form from a book which was so flawed that it was later hijacked by big time spammers and got my domain banned from most email servers out there.
Later on I tried to learn how to create dotabase driven sites with object oriented programming following the guidance of the excellent books, blog posts, and forums from Sitepoint and other sources. It was just too hard for my little brain. I just could not do it.
So what happened? 2 1/2 years ago I decided to learn Rails, which had just turned v. 1.1. It has been fun since the beginning and extremely rewarding. Working with Ruby is a pleasure, much easier to learn than PHP, and the Rails framework is so well put together that you can, with little effort, produce some very elaborate web sites with advanced features all while learning how to do proper object oriented web programming.
I used my new knowledge to recreate from scratch the site of my non-profit organization (with a new domain ;-) and, with a friend who is a talented designer, created a web development firm.
Don't get me wrong, it's not that easy, if you want to learn programming you need to put a lot of effort into it but in my own experience Rails can bring you some instant results while letting you get deeper and deeper over time.
I recommend two main sources of knowledge:
The excellent, official Rails
guides.
The free screencasts
from Railscasts.
Whatever your choice will be I wish you the best and a fun and fulfilling experience
I recently came upon this question myself. I really liked the way PHP integrates with HTML making designing a site more natural in my opinion. Design your site as you would with static content and then switch the static with the dynamic. However, I wanted to choose a "good" language. I looked at PHP, Ruby, Perl, and Python, as they are the most popular, open source options. I didn't need any powerhorses, if you will, like Ruby on Rails or Django, since I just wanted to mess around with server side stuff and some SQL—nothing serious. I don't remember why nor do I care to remember why, but I chose Python. But I still wanted that integration with HTML. I came across Karrigell. It's a neat piece of Python that essentially handles the integration. It comes with a little web server which you can use on its own or use something like mod_proxy with lighttpd. The devs don't limit you to only Python inside HTML, though. Their server parses: Python inside HTML, HTML inside Python, plain ol' Python scripts, and Karrigell services. It may not integrate as well as PHP does, but it's pretty damn good.

Categories