$30 off During Our Annual Pro Sale. View Details »

Desktop Apps with PHP and Titanium (ZendCon 2010)

Desktop Apps with PHP and Titanium (ZendCon 2010)

Appcelerator Titanium is an open source platform for developing native desktop and mobile applications using the web technologies you're familiar with. Web developers can use their skills to develop for both the Web and desktop/mobile apps. Ben Ramsey will demonstrate a simple application in Titanium Desktop, showing examples using JavaScript and PHP to power dynamic desktop applications.

Ben Ramsey

November 03, 2010

More Decks by Ben Ramsey

Other Decks in Programming


  1. Ben Ramsey • Zend/PHP Conference & Expo • 2 Nov 2010
    Desktop Apps with PHP and Titanium

    View Slide

  2. What Is Titanium?

    View Slide

  3. View Slide

  4. View Slide

  5. Desktop Apps with PHP and Titanium • Ben Ramsey
    Four main parts…


    ‣Language-OS bridge

    ‣Run-time shell

    View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. $9M in funding from
    Sierra Ventures and eBay!

    View Slide

  10. View Slide

  11. Using Titanium Developer

    View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. View Slide

  17. View Slide

  18. View Slide

  19. Desktop Apps with PHP and Titanium • Ben Ramsey
    Installation on Linux
    ‣There is a known issue with the GTK libraries for Titanium Developer
    on Linux

    ‣Until there is a fix, do this after installing Titanium Developer:

    ‣cd ~/.titanium/runtime/linux/1.0.0
    ‣rm libgobject* libgthread* libglib* libgio*

    View Slide

  20. “Hello, World!”

    View Slide

  21. View Slide

  22. Hello, World!

    Hello, World!

    View Slide

  23. View Slide

  24. View Slide

  25. var mainMenu = Titanium.UI.createMenu();
    var menu = Titanium.UI.createMenu();
    menu.appendItem(Titanium.UI.createMenuItem("Quit", function() {
    if (confirm("Are you sure you want to quit?")) {
    Titanium.UI.currentWindow.menu = mainMenu;

    View Slide

  26. View Slide

  27. Desktop Apps with PHP and Titanium • Ben Ramsey
    Titanium has APIs!















    View Slide

  28. View Slide

  29. View Slide

  30. PHP in Titanium

    View Slide

  31. <br/>// PHP code goes here<br/>

    View Slide

  32. <br/>var heading = document.getElementById("title");<br/>heading.innerHTML = "Hello, World!";<br/>

    View Slide

  33. <br/>$heading = $document->getElementById("title");<br/>$heading->innerHTML = "Hello, World!";<br/>

    View Slide

  34. View Slide

  35. PHP Info
    <br/>date_default_timezone_set('America/Chicago');<br/>ini_set('default_charset', 'utf8');<br/>ini_set('display_errors', 'Off');<br/>function getPhpInfo() {<br/>ob_start();<br/>phpinfo();<br/>return ob_get_clean();<br/>}<br/>

    <br/>$document->write('<pre>' . getPhpInfo() . '</pre>');<br/>

    View Slide

  36. Desktop Apps with PHP and Titanium • Ben Ramsey
    PHP caveats
    ‣echo does not work as expected

    ‣Titanium state transitions (links) do not send requests

    ‣Pre-processed scripts (.php) are processed at compile/build time

    ‣Cannot inject classes defined in .php into runtime code with include/

    View Slide

  37. The client-server
    relationship does not exist.

    View Slide

  38. Planet PHP Demo

    View Slide

  39. Wrapping up…

    View Slide

  40. Desktop Apps with PHP and Titanium • Ben Ramsey
    ‣I blog at benramsey.com.

    ‣I tweet at @ramsey.

    ‣Please rate this presentation at joind.in/2259.

    ‣Get the source code for my examples at GitHub.

    ‣Find out more about Titanium at appcelerator.com.

    ‣My company is Moontoast. Check us out at moontoast.com. Follow us
    on Twitter and like us on Facebook.

    View Slide

  41. Desktop Apps with PHP and Titanium

    Copyright © 2010 Ben Ramsey. Some rights reserved.

    Presented on November 2, 2010 at Zend/PHP Conference
    and Expo, Hyatt Regency Hotel, Santa Clara, CA.

    This work is licensed under a Creative Commons Attribution-
    Noncommercial-No Derivative Works 3.0 United States

    For uses not covered under this license, please contact the

    View Slide

  42. Desktop Apps with PHP and Titanium • Ben Ramsey
    Photo Credits
    ‣Titan-crystal bar from Wikimedia Commons

    ‣Titanium-cylinder from Wikimedia Commons

    ‣Apollo 17 full Earth photograph from NASA/Goddard Space Flight Center Scientific Visualization

    ‣titanium cylinder, GRADE 2 quality from Wikimedia Commons

    ‣Surface of a compressed cylinder of titanium from High-Res Images of Chemical Elements

    ‣Guggenheim Museum Bilbao from Wikimedia Commons

    View Slide