I want to try creating a canvas were multiple users can type and edit for brainstorming etc. I am thinking of php as backend. What are the technique used for it? For example, lets say its
pure text. How do we update the text like in the google wave(b4) and in google doc?
Is it just using websocket(or js pooling) and updating the text file? or are there any
better logical way to solve this issue?
Well, its not as easy as it is said in Brad's answer but he is partially right. You will definitely need WebSockets today to make it happen. But logically, it is not that simple to create a collaborative environment. There are issues like broadcasting changes of every user to every other user viewing the same document. Then you will have to make sure that every user gets to see exactly the same thing no matter who changes what and when. This gets difficult when multiple users are working on the same document collaboratively. There can be conflicts while merging changes of one another.
As far as PHP is concerned, language is not really a problem. Its how you handle the above stated problem.
Google released its research and engineering details on Google Wave (I guess after abandoning the project). This link might be some help to you: http://www.waveprotocol.org/whitepapers/
Websockets are the way to go for this. However, they are difficult to implement in PHP, and not supported by many browsers as of yet. You can do long-polling of AJAX requests pretty easily with PHP, but it can be quite a waste of resources.
This might not be what you are looking for, but I'd suggest changing your server-side technology. You can use Node.js with Socket.IO to easily use Websockets (or seemlessly emulate them for browsers that don't support them). This will provide the fastest method for pushing data to your users.
Related
I want to create an old school simplistic Text based RPG. No inventory, no fighting, just finding the right way through a dungeon.
There will be a describing paragraph about each "room" and there will be choices depending on the room. IE, If there's two doors, you can choose which to go through, or if there's items you can use them and so on. As you progress, the story unfolds.
I really want to use php for it, since I don't really know alot of programming and I hear that it's an relatively easy entrance for that. I already know enough php to develop for Wordpress, as well.
I really want it to remind people about the old MUDs, designwise i want to be like a terminal or the cmd. The styling is certainly no problem with css, but i'm still not sure about what to use to make the typing feel good, but i'm currently eyeballing tryruby.org and goosh.org to get the right feel.
Any ideas on how to go forth with that? What Do I need to use? Javascript/jQuery? Any good resources for me to look at?
EDIT: Ofcourse, it's online.
Extending #rmorero answer you can use my terminal emulator, so you don't need to recreate tryruby.org look and feel http://terminal.jcubic.pl and use JSON-RPC, you can use my php library for that https://github.com/jcubic/json-rpc
It all depends on your preference.
A quick way to get started would be a html/javascript frontend and a php backend.
The javascript frontend emulates a console, the implementation at goosh.org looks like great inspiration.
Callbacks can be done through ajax, jQuery is pretty useful here.
You could also take a look at Comet if you want to push content (sending content from the server to the client without the client requesting it - or using requests several times).
PHP for the backend sounds good, you'd just implement a script that returns each location, descriptions and possible exists. I'd recommend looking into the JSON format for this, as it will allow you to return an object like:
{
"title": "A dark room",
"description": "This is a very dark and scary room. The smell is obnoxious",
"exits": {
"nw" : " A small door",
"n" : "A huge ladder"
}
}
Php has built in functions to create json objects from php objects, i.e. json_encode.
You probably want some kind of database as well, to store the locations. Here it depends on what you want to use. You can use a traditional sql database (mysql, postgresql, etc), or a no-sql database (mongodb, redis, etc).
You should look into development frameworks for interactive fiction. The two leading development tools for terminal-style games are Inform and TADS, but Quest looks good as well.
If you want to have an even lower entry barrier -- or just don't want players to type in commands, but rather click on alternative choices -- you might want to look into Choicescript or Undum. Choicescript is extremely easy to use and great for writing strictly choice-based text-adventures. For Undum, you need to know some JavaScript, but you can do more things with it. (I extended Undum once to add RPG-like dice rolls, character sheets, etc.) Quest 5.3 introduced a "Gamebook mode", which makes Choicescript-style games very easy to build as well.
I should point out that none of these environments requires PHP or indeed any sort of client-server communication. One advantage of this is that you can distribute your games very easily: a static website is fine, plus your games can be played offline. Potential disadvantages are that you don't improve your PHP skills; that your games are singleplayer only (though Undum games could be made multiplayer with some effort); and that no matter which environment you choose, you are never quite as flexible as you would have been with plain Javascript or Javascript+PHP.
I've now got some very good understanding of (X)HTML and CSS, and plan to move on. My next choices are PHP and JS (and don't know if I'll ever end up learning one of them, but I would love to).
So, I need to choose one of them. I have learnt that PHP is server-side programming and JavaScript is client-side programming, and I am NOT asking you to compare the two of them for me. What I would like to know is, can I do anything (or most of) in PHP that can be done with JS? (or put it this way, can do everything people use JS for, on the server-side with PHP?)
Instances include, using PHP instead of JS in web themes, real-time content display (as in live blogging, live comments etc), effects etc.
This might seem dumb, and there's definitely a reason why people use JS in all the above instances, but since I cannot (really) learn the two of them, thought I should ask for some advise here.
EDIT: Would it be possible to reload only a part of a web page (not the entire web page) every few seconds with PHP? That should be good enough for the real-time application that I am planning.
If you absolutely don't want to learn both, then learn Javascript. There are possibilities to implement a Javascript-based backend with node.js.
I advise you to at least try PHP since it is widely used - maybe even at your company.
For nice user experience (dynamic menu, ajax, effects, ... ) you need client-side programming and for dynamic content you (almost always) need server-side programming.
In short, you need both.
PHP and JavaScript cannot really be compared in the way you're asking...
Both are powerful in what they've ment for and they have a very similar syntax. If you can't absolutely study more than one of them, learn PHP in my opinion. I coded with PHP for almost 10 years before really getting into JS. I would say PHP is the food and JS is the spice.
In order to create AJAX web apps Javascript AND a server-side language is required.
No, you can't. PHP only works on the server side. Once you've delivered content to the client, PHP can't do anything until the page reloads or the user loads a new page. If you want to do anything client-side in between, you need JavaScript (this includes loading content in real-time, doing a lot of modern UI stuff, etc).
Either learn both PHP and JS or use a blogging CMS and use a minimal amount of both.
If you put enough effort into it, you can do almost anything server-side using lots and lots of page reloads. You can also generate arbitrarily complex dynamic content using Javascript.
But it's a lot easier to do minor changes to a page's content from Javascript, it's only possible to do animations and effects from Javascript. It's also much easier to directly access the database from server-side code – there might be pure-javascript drivers for SQL databases, and you could use a NoSQL databases that's accessed using web services, but both are relatively uncommon techniques.
I have a thought regarding your original question/situation. I know this is about four years tardy, but I thought I should throw in my two cents for people who are looking back on this conversation as a reference from Google like I am. In your situation, because you are a blogger who is trying to save time when it comes to programming, I would recommend looking into WordPress (the .org version, not the .com). It is a sort of marriage of WYSIWYG blogging/website creation and programming. It takes care a lot of the back end stuff (including Javascript, PHP, and more), but also leaves it open for you to edit if you so desire. You probably could get away with using Wordpress as a total non-coder, but with HTML and CSS, you're already off to a great start. WordPress is super simple to learn and amazingly powerful. If you do take this route, I would suggest learning PHP as an asset because that is the language that WordPress runs off of. If you know PHP and are using WordPress, you have vast potential, not to mention that speedy blogging is a snap. If you don't feel the need to have whipped everything up from scratch and want to work faster, give WP & PHP a try. They'll take you a long ways.
I'm developing an app that is essentially going to pull data from a ton of different sources (twitter, facebook, github, basecamp, stackoverflow, etc.) and aggregate it all into a useful interface. Everything is going to need to be real-time.
I'm thinking that the majority of the app will avoid database usage - so the data I pull isn't going to be stored, it'll just be repulled and formatted everytime a user needs it. Obviously there is going to be a lot of AJAX involved and a lot of grabbing data from different APIs.
I'm most skilled in PHP, but I often times find it to be clunky, especially with this sort of thing. What language or framework would be the cleanest for pulling this kind of data so often, and quickly parsing it for the user? I know my way around Node.js and Ruby, but am very open to learning a new language/framework if need be.
all popular web languages are fine, but, i'd vote for node.js for the following reasons:
you know it.
easy for async networking to 3rd party services such as stackoverflow
your system won't be so snappy and node.js can handle many simultaneous clients.
php you know too and has curl that can do multi get to solve 2. but that won't help you with 3. ruby is in the same boat as php.
if one wants to make a website that acts like a desktop software, isnt it better to just use one page and use ajax to retrieve all other php-files and update the content of current page with eg. jquery?
i mean, just ONE page, you get the idea of my question i think...
is this to recommend? what is the pros and cons?
i mean, its really smooth!
That's how Meebo, Gmail, etc. do it, so there are clearly legitimate use cases. Do note that they have versions that work without JavaScript, to avoid losing audience...
It can work well to an extent, butONE page is 1 (or several) steps to far, it depends on the application.The main drawbacks are page history (forward/back) and bookmarking, both can be sidetracked.
It depends on your application. If accessibility or SEO are considerations at all, you should rely on AJAX only for enhancing the user experience in capable browsers.
First of all you should not create web apps that act just like desktop software (use Flash or Silverlight if you really need to) but design you application in a way that is suitable for the web.
However when creating web applications using AJAX is a good practice as it makes better user experience. It can also simplify the development as you can clearly separate the user interface from the functionality. You can use something like this http://yensdesign.com/2008/11/creating-ajax-websites-based-on-anchor-navigation/ to overcome forward/backward and bookmarking issues. The one big CON is that users without JS (many mobile browsers, but not only) won't be able to use your application.
#fayer, sure, you can create such a "single-page application". IMHO there's nothing wrong in using standard web technologies to create browser-based apps that look and feel like native desktop apps. The browser merely becomes a runtime in this case, you may additionally also consider using browser-based runtimes like Adobe AIR or Titanium.
Starting from scratch or only with a low-level library like jQuery it is not trivial (if not impossible) to develop, deploy and maintain larger desktop-like web applications, but with a proper framework it can be straightforward and fun: have a look at qooxdoo, http://qooxdoo.org , a mature open source JS framework which addresses all those RIA requirements. To get the idea of a large-scale qooxdoo app, check out the free webmailer http://gmx.com (think of "Outlook in a browser").
As a freelance developer I deal with clients mostly by contacting them via email/im.
That isn't working bad, but I'm thinking of a more professional approach with client communication panel for my website.
Client basically will be given login/password and access it to see previews and comment them.
I'm fine with writing the application myself, but since so many developers have similar things on their websites, maybe there already is some solution that I could just reuse?
//edit
well, I should probably explain myself a bit clearer.
I'm fine with showing websites as they're being properly built/coded.
It's just communication and design stage that I'd like to move from mail/im to some simple web application.
Theoretically project management tools would do, but they overly complicated and I need just simple functionality to comment (in threads ideally) and attach images. Probably will want more later, but that's all I can think of now.
It might already be 'overly complicated' but you could take a look at Request Tracker: http://bestpractical.com/rt/
"Accessing it to see previews" would mean vastly different things to different people - you probably just want to do something like having a password-protected preview area - if you're making websites it could live at http://preview.example.com for example.
There are various sorts of systems that might to the second part though, a Wiki might work, or FogBugz, or Trac.
I found collabtive being a brilliant all-in-one software.
Got all I really needed.