The Idea Basket
“When you find yourself wanting to jump on a design trend, ask this simple question: does this really work for me? Sometimes a trend is just a style that appeals to small number of people.”
— Jared White

December 2006

The End of an Era

December 29th, 2006

Hello everyone. I hope you had a wonderful Christmas season this year, and I wish you many blessings for the coming year.

I don’t know how many people know this, but this is actually the fourth (or fifth?) incarnation of The Idea Basket. It was originally a tech news and commentary site, which underwent several permutations and eventually closed. I started up this blog version of The Idea Basket in 2005, and I’ve been very happy with the format. However, in recent times, some major events have transpired in my life to cause me to reevaluate pretty much everything I’m doing. As difficult as this decision is for me, it is one that I feel is right. I’m closing The Idea Basket. This is the last post I’ll make, and I just want to say how much I’ve enjoyed posting here, and your comments and suggestions have been most appreciated.

The xajax project which I’ve been working on since October 2005 is still in business, and we’re very close to releasing Beta 2 of the new 0.5 codebase. A new Web site for xajax is also in the works, which will include a development blog managed by myself and rest of the xajax team. So you’ll still be able to get your xajax news from a familiar face. :)

Meanwhile, I’m in the process of embarking on an entirely new venture, a personal blog on Christian spirituality. Yes, it’s a completely different subject, but it’s one that has become a significant transformational aspect of my life the past couple of years. I’ll update this post when the site goes live.

Anyway, thank you again for being my readership, and I wish you all the best in 2007. God bless you!

November 2006

Some time off for Willowgarden

November 7th, 2006

As you may have ascertained, I’ve not had much time to work on Willowgarden for quite some time. I have to admit I was disappointed in the lack of interest in the Developer Preview 2 release from a community perspective. Perhaps it was partially my fault, since I never got a chance to flesh out the end-user documentation to the degree I wanted, and many an open source project has been stymied through a lack of simple, clear documentation.

However, I’ve been really happy with DP2 as a platform for my own Web apps and sites, and so I really can’t complain about any of the work I’ve put into it. One such project is the Native American Flute Portal which just launched today — yay! With a few exceptions, the entire site was built on top of Willowgarden, and I’m extremely pleased with how well it’s worked out.

Another PHP project that’s shifted my attention away from Willowgarden is xajax, which of course is used by Willowgarden for the Ajax layer. xajax is in the process of a huge rewrite leading up to a 0.5 release, and I’m happy to say we’ve had some pretty neat action there due to the addition of a new developer (”CtC” aka Joseph Woolley). Much fun on that front is yet to come.

So, to wrap this post up, Willowgarden has met my personal expectations from a technology standpoint, but as a viable open source project, it just isn’t there. So I’m going to maintain a pretty low profile for a while and put off another big marketing/release push (aka 1.0 Beta 1 or something like that) for some time. I’ll be checking in tweaks and minor improvements here and there in the Subversion repository, but that’s about it. As always, I’ll keep you folks posted here at The Idea Basket!

October 2006

Full up

October 6th, 2006

Geez, I haven’t posted anything here since the 19th? For shame! But it’s not completely my fault. Here’s a rundown of what I’ve been up to lately:

  • Launched a new Web site for Binary Sea, an electronic music group I recently co-founded with Shayne White
  • Rehearsing for upcoming gigs of aforementioned group
  • On the Commandtext front: finished major milestone of internal project and begining work on a new consulting project
  • Attended an awesome, Spirit-filled youth conference at my local church (guest speaker was Banning Liebscher of Bethel Church in Redding, CA). I love you Jesus!!!
  • Hammering away at the design and coding of a major “portal” site co-hosted by my flute maker friend Geoffrey Ellis
  • Released a low-profile Beta 1 of the upcoming xajax 0.5 release
  • Lots of other odds and ends

I think my life needs some simplificaton right now. The modern lifestyle is a constant drive to accomplish 120% of what we can actually do if we want to maintain health, comfort, and spiritual growth. I’ve made the decision to start trimming away at the edges. I’ll let you know how that goes!

September 2006

Willowgarden Highlight: Easy Processing of Form Input

September 19th, 2006

Welcome to this week's installment of Willowgarden Highlights. I'll be talking about processing form input and saving it via an archetype (domain model object), a very common task of any Web application.

In the bad old days of processing forms and saving each field to a column in a database row, you'd have to do a lot of manual gruntwork: accessing each field from the $_POST superglobal, checking the values, constructing the SQL query, connecting to the database and executing the query, and so forth. Wouldn't it be great if you could just import the form right into an object, and let it do the validation and the database saving based on just a few simple rules? Let's take a quick look at how that might work.

The easiest way to create a form ready for import is to use the WFFormCreator class that comes with Willowgarden. Here's an example of a form for entering a project task:

PHP:
  1. <?php
  2. $form = new WFFormCreator();
  3. echo $form->startForm("name: taskForm", "URL:", WFMakeURL('create', 'action'));
  4. $form->useNamePrefix("ProjectTask"); // this is important
  5. ?>
  6. <table>
  7. <tr>
  8. <td>Name of the Task:</td> <td><?php echo $form->newTextfield("name: name", "size: 30") ?></td>
  9. </tr>
  10. <tr>
  11. <td>Comments:</td> <td><?php echo $form->newTextarea("name: comments", "rows: 10", "cols: 60") ?></td>
  12. </tr>
  13. </table>
  14. <div><?php echo $form->newSubmit("title: Add This Task") ?></div>
  15. <?php
  16. echo $form->endForm();
  17. ?>

So what we're doing here is creating a form that will call the "create" action of the current page when the form is submitted. In the form, we output a textfield for the task name and a textarea for comments. But notice that line of code near the top that calls the useNamePrefix method of the form object? That sets up the form to use that prefix in the field name for each form element. So the actual name of the comments field isn't "comments" but is in fact "ProjectTask.comments". (Periods get translated to underscores in PHP, so in PHP you'd get "ProjectTask_comments" in your $_POST superglobal.) And of course, the name of the "name" field is in fact "ProjectTask.name".

Now in your page controller, you can write some very simple code to process the incoming form. Here's an example:

PHP:
  1. public function create_action()
  2. {
  3.    $task = new ProjectTask();
  4.    $task->importFromArray($_POST);
  5.    if (!$task->isValid()) {
  6.       $this->getRenderer()->assign("validationErrors", $task->getValidationErrors())
  7.        ->assign("task", $task)
  8.        ->render("add");
  9.    }
  10.    else {
  11.       $task->save();
  12.       WFRegistry::getRequest()->redirect("view/{$task->id}", "action");
  13.    }
  14. }

You can start to see where we're going with this. In the "create" action, we're instantiating a new ProjectTask object (a subclass of WFArchetype). Then we're importing data from the $_POST superglobal (which is by default filtered by the input filter that comes with Willowgarden to prevent Javascript and CSS hacks). The archetype is smart enough to check for the prefix of each form field to see if matches its own class name and import only those values. Then we're checking to see if the archetype is valid (i.e., all the form fields now stored in the archetype validate according to the archetype's validation rules) -- if it isn't, we'll obtain the validation errors and render the add form again; if it is, we'll save the archetype and redirect the browser to the view action with the new task's "id" as a path parameter.

Showing how to set up the ProjectTask archetype with database access and validation rules is beyond the scope of this article, but I hope now have a sense for how Willowgarden's Logic and Render layers (Controller and View layers in MVC parlance) work together very well to make your job as a Web developer much easier. One of the great things about the name prefix feature is that you can use multiple prefixes in the same form, allowing you to import the exact same form array into multiple archetype classes without causing any conflicts. You can also use prefixes for the id of form elements, which is a feature I'm using a lot in one of my applications.

And that's it for today's Willowgarden Highlight! Come back soon to learn more about this exciting new application platform for PHP 5.

Willowgarden Highlight: Template Modes

September 12th, 2006

Welcome to the first post in a series of posts I'll be writing about highlights of the Willowgarden application platform for PHP 5. This first highlight may be a simple one, but it's a very useful one as you will shortly find out.

Willowgarden, like many Web frameworks, is built around the concept of pages and actions. A page such as "photo" might have actions such as "view", "edit", "remove", etc. Some actions are visual and don't alter content, and some actions do alter content and aren't visual (they redirect to a visual action). The visual actions, of course, need to output HTML to the browser. How does that work? Well, as you might think, every page has a template associated with it, which you use via the page's built-in renderer to render the template. But, unlike many Web frameworks, Willowgarden doesn't provide a different template for every action. All actions are provided via a single template file for the entire page. This works because of the concept of template modes. (Note: for the purposes of this article, we're assuming we're using the default PHP-based template engine.)

Say someone wants to edit information for a photo. They'll go to a URL such as http://www.mysite.com/photos/edit/12345, which means the edit action of the photos page will be called and the first path parameter will be 12345. Now obviously you only want the HTML for the edit action to be rendered; you don't want the HTML for the view action or the process action or whatever to be rendered. So in the template file ("photo.php.tpl"), you would do this:

PHP:
  1. <?php
  2. if ($this->getMode() == "view"):
  3. ?>
  4. <p>Hello. This is the view action template.</p>
  5. <?php
  6. endif;
  7. if ($this->getMode() == "edit"):
  8. ?>
  9. <p>Hello. This is the edit action template.</p>
  10. <?php
  11. endif;
  12. // and so on and so forth
  13. ?>

Not bad, eh? Of course, the tradeoff of more files that are simple vs. fewer files that are slightly more complex might seem like a draw. But, and this is a big but, this template isn't in and of itself action-specific. So you can do tricks like this:

PHP:
  1. <?php
  2. if ($this->getMode() == "add" || $this->getMode() == "edit"):
  3. ?>
  4. Welcome to the <?php echo ucwords($this->getMode()) ?> area.
  5. <?php
  6. endif;
  7. ?>

Aha! Now we're handling two different template modes in one pass. We can have specific bits of the template for either action output different HTML based on the mode but keep much of the HTML the same. This is very helpful when we deal with "add" vs. "edit" -- 90% of the page content might be the same in either case. With sophisticated use of template modes, you can keep 90% of that HTML in one single place. Bottom line: managing your HTML templates just got a whole lot easier.

I hope you enjoyed my first Willowgarden Highlight. Come back soon for #2!

Programming…via the GUI?

September 11th, 2006

The idea of programming via a Graphical User Interface rather than typed code has been around for a long time, but it's never caught on because usually the solutions are still too hard and abstract for non-programmers to grasp and too cumbersome and clunky for power users comfortable with whipping out cryptic text-based jargon while drinking coffee at the local Starbucks.

But one project that's trying to go beyond the limitations of both approaches and invent a new programming paradigm is Subtext. It is both a programming language and a development environment, and the demos I've seen of it are quite impressive. It's given me some ideas to chew on in regards to some of my own development with PHP.

Let me put it to you straight: I'm not a big fan of code generation at all. But I'm also not a big fan of typing repetitive boilerplate code over and over again. Maybe it would be possible to offload some of the basic tasks applications typically need to perform to a specially created setup environment that bears some resemblance to Subtext? Interesting.

Developer Preview 2 of Willowgarden has been released today

September 8th, 2006

Willowgarden is an application platform/framework for PHP 5 that I started work on towards the end of August 2005, with serious development progress starting around the beginning of the year. On April 28, I released Developer Preview 1 of Willowgarden, and while that was a good start, I knew that the project still had a long way to go before it would resemble the level of quality and scope of functionality that it really deserved.

Well today, I'm so pleased to announce that Developer Preview 2 is ready. This is where the project is really starting to solidify and settle into a cohesive whole that can be used for hands-on development. I've been working on several Web site and applications using the DP2 codebase, and it has made my life as a PHP developer so much more fun than the bad old days of cobbling together scripts nearly from scratch.

Along with DP2, I've set up a new wiki that houses the partially-complete Users Guide as well as areas for future tutorials, how to's, and more. I'll be spending a lot of my time in the near future working on that end of things rather than code. You are most certainly welcome to contribute content to the wiki as well, so be sure to check that out.

And now I am going to make a bold statement: I am asking the cutting-edge PHP 5 developers reading this -- and I know you're out there! -- to consider joining the Willowgarden project if it piques your interest. I would like to start moving interim versions out there at a more rapid pace, leading towards a stable 1.0 release of Willowgarden, and to do that I need the help of people with many different environments and expertise in fine tuning installations. I also have a huge number of ideas in store for future versions, and I'm sure you do as well. This is the time to get on board while the project is still young! To contact me, feel free to send me an e-mail (remove everything after jared before the @ sign).

Thanks for reading, and I hope you download Willowgarden DP2 and give it a thorough look-over. This release is stable enough that I encourage you to start using it for your experimental development efforts, and your feedback and ideas are very much appreciated. Also, I'll be posting a lot here now about DP2, so check back soon for more information as well.

Willowgarden DP2 coming today!

September 8th, 2006

Hi folks -- just a quick note to let you know I'm on track to release Developer Preview 2 of the Willowgarden application platform for PHP 5 later today. Check back soon!

Just a tiny delay

September 4th, 2006

Silly me! I forgot today, Monday, is Labor Day here in the U.S. I also got a couple of projects that came up at work suddenly, so I've decided to push back the release of
Willowgarden DP2 'till the end of this week. Thanks for your patience! It'll be worth it. :)

August 2006

Cross your fingers! September 5 = DP2

August 30th, 2006

Willowgarden is a PHP 5 application platform that enables you to build fantastic Web applications. The Developer Preview 1 release, which came out in April, was really just a sneak peak of what was to come. Now we're almost ready for the Developer Preview 2 release, which is a much more robust, full-featured, exciting platform that will build far more awareness of the project (and having a true Subversion repository available for open source access is also a big help).

I've picked September 5 as the launch date for DP2. I'm working hard to make this a reality, so definitely mark your calendars and come back here next Tuesday to experience the next generation of Willowgarden. I'm sure looking forward to it!