Page created:
Jun 16, 2009 (? ago)
Last modified ? ago
To main page | Opera Unite HowTo's

From PHP to Opera Unite

I highly doubt Opera Unite even plans to support PHP (but that's not a problem for PHP guy - some of the stuff is even simpler).
If you are experienced in PHP - see Uniteness
Right now you can't run PHP under Opera Unite. Instead of PHP you write "server"-side code in JavaScript. It's actually pretty simple to use JavaScript instead of PHP. See basic howto for example app.

I don't think Opera would be planning to use PHP as a language, since their main market is web browser and those use JavaScript. Generally speaking JavaScript is more secure, since it has less ways to deal with files and SQL. You can still use files, see sandbox filesystem. You also have templating system.

Besides, using just HTML+JavaScript for both presentation and server-side code is easier than using HTML+JavaScript+PHP+MySQL.

"PHP" to "Opera Unite" equality

"Apache/Web Server" -> "Opera browser" (it runs small browser inside)

"PHP" -> Server-side "JavaScript"

"MySQL" -> Not required (see persistence and performance)
Currently storing JSON in File has enough raw power (800req/s) to be used for data storage. There are other ideas that I work on and test.

"Human readable URLs" -> See URLs

"index.php" ->
webserver.addEventListener('_index', start_page, false); 
// see Basic HowTo
"print" ->
function start_page(r) {
    var o = r.connection.response;
    o.write('This is printing');
php_info -> unite_info (find all kinds of available variables here)


templating -> Markuper (follows MVC pattern by design)

file_get(put)_contents -> file_wrap.js

file_get_contents('http:// -> HTTP connections
(but it needs to be async (deferred), I will probably need to elaborate on that)

I've simplified a lot of this in Uniteness


Another major difference is that variables are not reset at the end of the page request. So if you define:
var counter = 0;
then in function that returns the page you do:
Then counter would be incrementing each time someone visits a page, whereas PHP forgets all variables right after page generation is done.

Basically, your application never reaches end of script (until user closes Opera or
stops the service).

In theory

In theory you can have local Apache/PHP installation and make a service that accesses it via JavaScript (as a proxy) from Opera Unite, but this is really pointless, since the point of Opera Unite is to simplify stuff, not complicate it.


Since you don't have to deal with SQL - you don't have SQL injections.

Since you don't have write access to your 'application' mount point - you can't execute malicious code. And even if executes - it can't touch your code (since it's on read-only mount point).

Your computer can't be DOSed.

XSS is still an annoyance and security concern, but Markuper escapes most of what you insert.

Slava V. [about me]

main page

Last updated

  1. Markuper (HTML templates)
  2. .ua
  3. Opera Unite HowTo's
  4. .us (files)
  5. Distribute Your Application
  6. 24/7 sites (permanent applications - idea) [stub]
  7. Issues
  8. HTTP Connections (AJAX/REST)
  9. Cookies
  10. file_wrap.js - File Wrapper
  11. Basic HowTo: Simple app (tutorial)
  12. Static images, client-side scripts
  13. Application Examples
  14. How to Debug Opera Unite apps
  15. Persistence & databases
  16. Opera Unite benchmark
  17. From PHP to Opera Unite
  18. Uniteness (Framework)
  19. Config.xml
  20. Key-value storage
  21. Widget Object
  22. Notifications (Growl'esque)
  23. Reset (debug)
  24. Cron example
  25. What I meant by CNAMEs
  26. Wish List
  27. Device Unavailable
  28. StopLorem (Opera Unite blogging)
  29. uniteness-0.11
  30. GET/POST data
  31. CRUD And Static (example)
  32. Opera object
  33. URLs
  34. Headers & Redirects
  35. Error Console
  36. JSON State (storing data)
  37. Security
  38. /storage/ (in fileio)
  39. Yusef library
  40. unite_info (a-la php_info)
  41. Javascript Imports
  42. onunload / _close
  43. fileio: Sandboxed Filesystem
  44. Request Hierarchy (like php_info)
  45. Intro: Web Apps with Opera Unite