Let me say this first: I do not believe in big bloated MVC PHP frameworks. I believe in having custom code that runs as fast as possible. For recurring useful functionality, such as templates, I believe in using simple, efficient and flexible dedicated standalone modules.

For the past several years, I have been using a home-grown templating system that functioned by parsing template files which would have a dedicated / invented syntax. It would replace, for example, %TAG%, with a value. It had several more advanced features too, such as conditionals, recursion, embedded PHP, and more.

And while it functioned just fine, it implemented a custom parser, and required templates to be written using a non-standard syntax. But, after having used Ruby on Rails, I was inspired to design something better.

ATTemplate is the result of this. The main idea behind ATTemplate is that PHP in itself is already a parser, so why reinvent the wheel?

ATTemplate is very lightweight and relatively simple, but it’s very powerful without being bulky. It allows for everything the other templating systems can do, including loops, nested templates, recursion, conditionals, etc.

How to use

Here’s how you’d use ATTemplate:

<?php

// Include the ATTemplate class
require_once 'attemplate.inc.php';

$template = new ATTemplate();

// Optionally, you can give it properties, like so:
// $template = new ATTemplate($property_array);

$unread_messages = rand(0, 20);

// Sets property 'unread_messages' to 10.
$template->set('unread_messages', $unread_messages);

$template->set('title', 'ATTemplate Test');

$property_array = array(
    'first_name' => 'John',
    'time' => date('H:i:s'),
    'friend_requests' => array(
        array('name'=>'James', 'followers'=>rand(0, 200)),
        array('name'=>'Josh', 'followers'=>rand(0, 200)),
        array('name'=>'Aaron', 'followers'=>rand(0, 200)),
        array('name'=>'Eric', 'followers'=>rand(0, 200)),
        array('name'=>'Mike', 'followers'=>rand(0, 200))
    )
);

// This pushes the content of $property_array into the properties
$template->push($property_array);

// Prints the parsed template
echo $template->parse('index.phtml')

?>

And here’s what your template could look like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

    <title><?php echo $title; ?></title>

</head>

<body>

<h1>Welcome, <?php echo $first_name; ?></h1>

<?php if($unread_messages>0): ?>
<h2>You have <?php echo $unread_messages; ?> unread messages!</h2>
<?php endif; ?>

<p>You have received friend requests from the following people:</p>
<ol>
<?php foreach($friend_requests as $friend_request): ?>
    <li><?php echo $friend_request['name']; ?> (has <?php echo $friend_request['followers']; ?> followers)</li>
<?php endforeach; ?>
</ol>

<p>The time is <?php echo $time; ?></p>

</body>
</html>

License

You’re free to use the code in whatever you want, commercial or not. Modify it, redistribute it, do whatever you want with it.

The only requirement is that you need to give me credit.

Also, please do shoot me an email if you use this in your project.

ATTemplate by Kenneth Ballenegger is licensed under a Creative Commons Attribution 3.0 United States License.
Based on a work at www.seoxys.com.

Download

Download ATTemplate!

Meet iLaugh 2.0 – Social Jokes

After months of hard work, controversy and perseverance, iLaugh 2.0 is finally launching.

iLaugh puts a database of over 50,000 jokes in the palm of your hand. Vote on your favorite jokes, compile a list of your favorites, share jokes with your friends via Twitter and Facebook, and most importantly, have a good laugh.

With iLaugh, you have complete control over which jokes you want to read. The Categories feature gives you the ability to only read the jokes that interest you. Additionally, you can filter out adult jokes or jokes voted down by the community.


(click on the image to go to ilaughapp.com)

Warmonger: Warcraft III Autorefresh for Mac OS X

One of the most popular articles on this blog has always been my tutorial on how to hack an War3 autorefresh bot for Mac.

However, it’s still quite a clunky hack, and many commenters have been unable to get it work smoothly. Even I gave up on it when I upgraded to Leopard.

Introducing Warmonger

Warmonger is a Mac-like autorefresh bot for Warcraft III. It does that and only that, but it does it well, reliably and most importantly, natively.

Warmonger is completely free, too.

Download Warmonger

Using Warmonger is easy: Create a game on Battle.net, switch to Warmonger and hit Refresh, get back to War3 and enjoy your autorefreshing game.

Warmonger knows to stop automatically when your game starts. Once it’s launched, you don’t even have to worry about it anymore. It really is that simple.

Apple’s Increasingly Ridiculous Rejections

Three months ago, I submitted an update to iLaugh and iLaugh Lite, numbered 1.1.1 that fixed many bugs but didn’t change anything to the functionality of the app.

Today, after three whole months in review (seriously, I’m not making this up!), they decided to finally tackle the issue and issue me a rejection for no other reason other than “because we said so.”

See for yourself.

Please note, this is for iLaugh 1.1.1. iLaugh 2.0 is still in review, as a new application, and there’s no reason it should be rejected. In fact, the premium edition has already been approved and is already live on the App Store.

Speaking of iLaugh 2.0 – the first public screenshot ever:

On The App Store Hype

A while back, TechCrunch covered yet another article complaining about the App Store being more of a Lotto than a marketplace. Setting aside the App Store’s numerous other issues, coverage of iPhone app developers has been divided into two extremes: reassuring yet unlikely success stories, or depressing yet much more likely failure stories.

The general question in all of these articles is: “Can an average guy become a successful iPhone developer?”. The answer depends on how you define success, and on that topic I can speak from my own experience.

If, to you, success means making a million bucks overnight you will most likely be unsuccessful. To me, success is defined as the return on my investment (both in time and money) on the project. In my previous article, I mentioned making somewhere around a hundred dollars a day on iLaugh. However, I didn’t mention how much I invested in the project.

The first version of iLaugh and its subsequent revisions took me very little time to create. I estimate that I invested between ten to twenty hours of my time to create iLaugh 1.0. At my asking rate of $100 per hour, that represents a $1,000 to $2,000 investment. The server running the first iteration of the iLaugh API cost me about $100 per month to maintain.

If you look at the numbers for iLaugh from previous months, I make over $3,000 monthly (for a total of over $8,000 so far). Thus, I consider it a success.

Many people, in response to my previous article, said that I too, was one of the lucky ones, albeit on a smaller scale. And while that may be true, considering the low quality of that first iteration of iLaugh, a more carefully crafted app would likely have done better.

I believe the potential for success is relative to the investment put into anything.

If you look at the familiar success stories, many of them involve reinvestment and good marketing. For instance, Tapulous hit the jackpot with their Tap Tap games. Being good friends with one of their employees, I know exactly how much work goes into their production.

Perhaps one of the most talked-about success stories is Trism. Its developer, Steve Demeter, made an insane $250,000 in just two months. What I believe is the key to Steve’s long-term success, is that instead of buying a fancy sports car, he reinvested his money into founding a sustainable business.

Part of reinvesting, and a facet of development often ignored, are things that a typical developer can’t do. Most importantly: design, copywriting and marketing. These are things that will most likely have to be outsourced. Developers are reluctant to do that, because it’s very costly, but in the end, ignoring it is going to cost them the popularity of their application.

I view iLaugh 1.x as a catalyst towards bigger and, hopefully, even more successful endeavors.

In fact, I have already put a big part of my (in comparison to the numbers above, quite mediocre) earnings into the second iteration of iLaugh. I’ve hired a bunch of people much more talented than I am in their respective fields, and iLaugh 2.0 is coming along really nicely. It will be entirely different and nearly incomparable to the first iteration. There are some very cool things coming.

So, responding to my initial question: “Can an average guy become a successful iPhone developer?”. Yes! An average developer can be successful in the App Store. But it takes hard work, a lot of time, money, and perseverance.