Archive for October, 2009


Building Titanium with PHP

Mon, 5 Oct 2009 19:48 UTC

Several months ago, I started the process of embedding PHP into the Titanium platform. After several sprints of work, the Appcelerator team was finally ready to merge my work into their master branch, and Martin Robinson worked to bring the implementation to maturity. The current release of Titanium Developer does not yet have the PHP support built in to the bundled SDK, and I’m not sure when it will be released, so I thought I’d share how to get a development version built with PHP support so you can start playing with it and even help the Appcelerator team by catching bugs in the implementation.

If you’re not familiar with Titanium, it’s a development platform that allows you to build native desktop applications for Windows, Mac OS X, and Linux using the Web technologies we use on a daily basis: HTML, JavaScript, CSS, Python, Ruby, and now PHP. Titanium is built on top of WebKit, and it includes a micro-kernel called Kroll that does all of the pre-processing and runtime processing of the code. Languages are modules in Kroll and are first-class citizens in the runtime environment. So, when using the runtime, you can pass objects back and forth between JavaScript, PHP, Python, and Ruby. This, however, can’t be done when using pre-processing mode, but in that case, your PHP scripts will work just like you’re used to them working on a web server.

Since it may still be a while before the next release of Titanium that includes PHP, I’ve decided to provide instructions here on how to build the SDK from the master branch and connect it to the Titanium Developer application. Sorry, but I don’t have instructions for Windows; these work on Mac or Linux.

  1. Download (and install) Titanium Developer from http://www.appcelerator.com/products/download/
  2. Launch Titanium Developer and let it do its thing (you’ll have to create an acct)
  3. Now you may close it
  4. You should now have a Titanium directory with the SDK in it at either:
    • /Library/Application\ Support/Titanium/ (Mac)
    • ~/.titanium/ or /opt/titanium/ (Linux)
  5. Now, build the development SDK to use with Titanium Developer. You’ll need Python, scons, a compiler, and possibly other prerequisites.
    $> git clone git://github.com/appcelerator/titanium_desktop.git
    $> cd titanium_desktop/
    $> git submodule update --init
    $> scons dist
    
  6. Unzip the built SDK to some location. I like to use ~/.titanium-dev/
    $> unzip build/osx/dist/sdk-0.7.0.zip -d ~/.titanium-dev/
    
  7. Move Titanium Developer SDK out of the way and point to your build SDK
    $> cd /Library/Application\ Support/Titanium/
    $> mv modules/ modules-old/
    $> mv runtime/ runtime-old/
    $> mv sdk/ sdk-old/
    $> ln -s ~/.titanium-dev/modules modules
    $> ln -s ~/.titanium-dev/runtime runtime
    $> ln -s ~/.titanium-dev/sdk sdk
    
  8. Now relaunch Titanium Developer.

You’re now ready to build a project with PHP!

Click Create to generate a stub project. I’ll cover more about development with PHP in Titanium in the future, but let’s get started by showing a phpinfo() page.

Open the index.html file in the Resources directory of your project and add the following anywhere in the page:

<p><a href="phpinfo.php" style="color:gray;">See the phpinfo()</a></p>

In the Resources folder, create the phpinfo.php script and add the following to that script:

<?php phpinfo(); ?>

Now, go back to Titanium Developer, click the Test & Package tab for your project, then click the Launch tab. To build and run your application for testing, click the Launch App button.

You should now see a dark gray test page with the “See the phpinfo()” link you created. Click that link, and it should take you to the phpinfo.php script you created with the proper phpinfo() output. Congratulations!

Visit the Appcelerator Codestrong developer center for more information on building Titanium applications. Visit #titanium_app on Freenode IRC to ask questions about application development. If you want to help develop the project and contribute PHP tests to it, join #titanium_dev.

Comments 12 Comments »  Permalink Permalink  Tags Tags: , , ,


CodeWorks Days 11 & 12 (Washington)

Sat, 3 Oct 2009 21:51 UTC

Departing Miami, I gazed upon the Atlantic Ocean as we cut through the clouds, making our way farther from the shore, and the thought occurred to me that this tour—these two weeks—has taken me from sea to shining sea across this great country. What a fitting thought to have as this next leg of the tour took us to Washington, DC.

I have traveled the country and have engaged the PHP community face-to-face all across it. It has been a great experience and an excellent opportunity to connect with the PHP community at all ends of the United States. Perhaps a tour to other parts of the world is in order, to connect with the community on a global scale. If I’m ever afforded that opportunity and privilege, then I will be certain to evangelize the PHP Community in each location, hoping to grow our community, bringing in new faces and new ideas.

As I mentioned, our next stop was Washington, DC. Some of us took advantage of free time we had on the afternoon and evening of the tutorial day to visit the city and walk the Mall of the United States capitol. We walked from the Washington Monument to the World War II Memorial, along the Reflection Pool to the Lincoln Memorial, along the Viet Nam Wall, around the Ellipse, and to the White House. Andrei remarked that he was using this opportunity to “consumate his citizenship.” Finally, we had dinner at the Old Ebbitt Grill, apparently the oldest saloon in Washington.

After dinner, our small group met up with some of the other speakers and conference attendees at The Brickskeller, where we enjoyed each other’s company and some great beer—they have other 1000 beers.

The session day went well. After some technical difficulties with my HTTP presentation, I managed to get started, and one of the attendees even remarked that he thinks my talk is perhaps the most important one at the conference. That’s the best compliment I’ve ever received. Everyone stayed for the end of my talk, which ran fifteen minutes late, eating into the lunch period. My AtomPub talk later in the day was much smoother in delivery.

As I wrap up in Washington, I’m left wishing that I had more time to explore the capitol, but now it’s time to move on to New York and the last leg of our tour. I’m one step closer to going home, and while I’ve had a great time on the tour meeting new people, giving presentations, and hanging out with old friends, I’m ready to go home to my family.

I hope to see you at New York CodeWorks!

Comments 3 Comments »  Permalink Permalink  Tags Tags: , , ,


CodeWorks Days 9 & 10 (Miami)

Sat, 3 Oct 2009 19:49 UTC

Miami CodeWorks, so far, was the smallest conference but I still think some important connections were made, especially with regard to user group contacts.

At the Microsoft happy hour on the second day of the conference in Miami, I was able to meet Brendon Van Heyzen, who is interested in starting up a PHP user group in Boca Raton. It seems that the Miami PHP user group has quietened down and gone silent, and he’s interested in starting up a group for the Boca Raton PHP community. We had a great discussion, and I offered him some points of advice on how to start a group, and this reminded me of the user group starter package I’ve discussed with Rafael and Michelangelo. I really need to push the PHP Groups initiative to get started on this.

The two main pieces of advice I offered were to start a mailing list and then to find adequate meeting space. The mailing list is important to get discussion going and to see what kind of group the people in your area want to have. It will inform your search for meeting space so you can find the kind of space that will work best for the type of meetings you want to have.

So, CodeWorks has been an excellent way to reach out to local leaders and people who want to start groups in their areas. If you’re interested in starting a group, join the PHP Groups mailing list and introduce yourself.

Rounding out our visit to Miami, I enjoyed some great Cuban food at Puerto Sagua, and we actually managed to find some good beer at The Room in Miami Beach. It was a beer oasis in the midst of a desert filled with mojito sand.

Comments No Comments  Permalink Permalink  Tags Tags: , , , , ,


CodeWorks Days 7 & 8 (Atlanta)

Thu, 1 Oct 2009 15:48 UTC

Atlanta was the mid-point stop on the CodeWorks tour, and since it’s my home, I decided to use it as an opportunity to spend time with my family before heading off on the second half of the tour. As such, there was very little hallway track activity for me, but I did get a chance to make it to a few events.

I’m told that Atlanta has had the largest CodeWorks crowd yet. I took a quick look around at each of the rooms, and I believe it. Each presentation was well-attended, and I’m proud to say that the Atlanta PHP user group was well-represented this year; I saw lots of familiar faces.

Speaking of Atlanta PHP, we had a good crowd at the Meet the Speakers dinner on Monday night. Many of the speakers attended, as well as attendees and Atlanta PHP members. I want to thank Glen Gordon and Microsoft for sponsoring the dinner. I think it was a great success, and we couldn’t have done it without Glen’s help. The only problem I have is that many people apparently treat meetup.com “yes” RSVPs as mere suggestions. If there’s a chance you’re not going to make it, please RSVP “maybe” or “no.”

I also want to thank Jeff Jones for hosting an after party as his place for many of the speakers. It was a lot of fun, and the beer was great.

Now we’re in Miami, and I’m a bit behind on blogging, but I’ll post about the Miami CodeWorks stop later today.

Comments 1 Comment »  Permalink Permalink  Tags Tags: , , ,