Zend_Loader

My ZF adventures take me to the Zend_Loader class today.

What is that, you ask? Zend_Loader provides methods for um, loading, files and classes in your web application. Delving into Zend/Loader.php reveals the following methods:

loadFile() – this is basically a fancy include statement. it takes in three parameters: a filename, directories to search (one or multiple — if blank, will search include path), and once, which tells it whether to do an include() or include_once(). the difference in those is that include_once() will only let you load a file once on a page, regardless of how many times it is called.

isReadable()
– determines whether a file can be read or not. this uses the fopen() function with a read parameter to get its answer

_securityCheck – this is a protected class, which means that only this class and ones that extend from it can access it. this method determines whether a filename is legit. it uses a fancy regular expression to check this: '/[^a-z0-9\/\\_.-]/i', which I’d like to come back to eventually and make sure I follow

_includeFile – this is also a protected class and is similar to loadFile(), but, this doesn’t allow a directory to be set. it does, like loadFile(), let you specify once.

loadClass() and autoload() – loads a specific class. it looks like autoload() calls loadClass() and thats about it, so not sure what the difference is.

registerAutoload() – automatically loads a class when it is called in the code (so you don’t have to).

So for example:

At the beginning of the bootstrapper file, we have the code:

require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();

$config = new Zend_Config_Ini('settings.ini', 'development');

By using registerAutoload(), I avoid having to write

Zend_Loader::loadClass('Zend_Config_Ini'); prior to using Zend_Config_Ini.

What happens if you leave this out? Chaos:

Fatal error: Class 'Zend_Config_Ini' not found in /home/content/.../html/indextest.php on line 14

Link@Startup Business Models

Interesting article about getting value from your customers:

“It costs less and less for us to get up and running. Still, sooner or later – you need to make money. By not getting value back from users, we’re increasing the failure rate of our businesses.”

It still boggles my mind when I read about a company with $0 in revenue getting a muiltimillion dollar valuation. I can see indirect value, as in Google News bringing more people to Google, which makes Google more money in the long run. But for something like Twitter to be valued at… what? $75m? I can’t fathom that.

One day this’ll all make sense.

Update: This article by Greg Sterling, an eBusiness guru, expresses similar concern:

Stepping back, it strikes me that there’s something quite “dysfunctional” going on in the way that many entrepreneurs and funders think about building online businesses. Historically people in the real world who start businesses have not gone in with the attitude: in three years someone will buy me and I’ll never work again or maybe I’ll go start another business that will be acquired in another three years.

Google Should Do This

(if they don’t already)

TechCrunch recently had an article on how Google is experimenting with a Digg-like voting system for search results. The idea is that next to each search result you’d have the option to vote the site up or down based on your opinion of it. Google would then save your results so that the next time you search for the same thing, your changes would be reflected in the results.

Presumably, Google will eventually factor our votes into its ranking algorithm, which would have an effect on a site’s overall ranking. For example, IconArchive.com is currently the third highest ranking site when you search for free icons. If enough people voted for it with the new system, the search algorithm would nudge it into the number two position.

Manual feedback, if done correctly, could be a useful improvement to Google’s search algorithm. However, there are some significant problems with it. First, it would clutter Google’s search results, which might drive more people away than it would bring in. Second, and most important, it would be difficult to interpret the results. If I vote on a site before I visit it, my vote is irrelevant. If I’ve already been to the site, I’ll probably get to it by typing it in directly or by going through my bookmarks, so I’ll never get the opportunity to vote on it. The ideal result would be if I returned to Google after I visited the site so I could vote on it, which I probably wouldn’t do. Plus, if I returned to the search results, I probably didn’t find what I was looking for anyway.

Here’s a better, simpler way: When I search for something, keep track of which search results I click on. Next time someone makes the same search, Google should give more weight to the last site I visited. Why? I probably found what I was looking for on the last site, so it should be ranked higher in the search results.

Back to the example. I search for “free icons”, click the first site. Not a big fan of the layout, can’t find what I’m looking for, whatever. Same with the second site. Next, I get to IconArchive and voila, I find what I’m looking for – no more clicking search results. Google automatically tracks this and if enough people follow a similar pattern, IconArchive is promoted to the number two position.

This method is not without its own problems. The major problem is that people often stop searching because they can’t find what they’re looking for; they abandon their search. It might be difficult to distinguish between people who give up and people who find what they’re looking for because to Google, they probably look very similar. Google employs some smart folks, I’m sure they could figure out clever ways to analyze the data to distinguish hits from misses with a high probability. Even if they can’t, and they can, the results would still be better than the current results.

With millions of people searching Google each day, there is an enormous amount of untapped data which could reshape Google’s search results, providing more relevant information to people faster. Best of all, no annoying extra buttons on the results page.

Progress

I’ve been making my way through several books and wanted to provide an update.

Web 2.0: A Strategy Guide – I made it about 75% of the way through, and put it down for good. I found it very repetitive and suspect I’m the wrong audience for the book. This Slashdot review summed it up pretty well for me:

Web 2.0 is so much more than a technology.” Priceless. I can sum up the entirety of this book quite simply: If you want to be “Web 2.0″, develop a web application that is social-based, use plenty of Flash or Ajax (Ajax preferable), and create an API that allows script kiddies everywhere to fashion useless add-ons (preferably that involve cute icons of small furry animals or various celebratory trinkets). That’s the Foreword, Prologue, and Chapters 1-5. Chapters 6-10, Epilogue, and Appendices are as follows: The magic behind the Web 2.0 movement is this: the generation of kids nowadays have grown up using computers, are computer savvy, and are used to being online. So websites have become portals for social interactivity. The more interactive you can make the sites, the more “social” they become. So ends the mystery of Web 2.0.

Practical Web 2.0 Applications with PHP is coming along well — I’m about a third of the way through the book. The fifth chapter, An Introduction to Prototype and Scriptaculous, was a relief from the confusing Model-View-Controller. Now when I do a View-Source, I see links to those libraries and proudly say to myself I know what those do. For now, my knowledge is entirely theoretical.

Designing the Obvious – This is the fourth book on web usability I’ve read in the last few months, and one of the best so far. Robert Hoekman’s writing style is the same as his preferred design style: simple, clean, and to the point.

Also came up with a web application idea while reading an article in the WSJ this weekend. A quick internet search reveals there isn’t much competition, and this is something I would use and think others would too. Its perfect for a freemium business model. Best of all, I even got the usually difficult “Thats not a bad idea” from my wife, so it must have potential. Once I get through the PHP Web 2.0 book, I’ll start on it, unless another, better idea comes along.

I must admit, after taking a break for the last few weeks to get education about this stuff, I’m anxious to start hacking away at a new project.

I recently started posting on Hacker News (see here) and have been immensely impressed with the feedback my posts have received. I haven’t commented much on other peoples’ posts, mostly out of a lack of insight/knowledge, but I’d like to give back one day. Actually there’s another site idea brewing, where I might be able to do just that.

Peace -