Archive for February, 2010

Lithium PHP Framework

Last night I attended a presentation on “Lithium” by Garret Woodworth (@gwoo on Twitter) at the OCPHP Meetup.

Lithium is a fast and lightweight PHP framework. Garret’s presentation started out with kind of a history of PHP and some of the new features in PHP 5.3 — which they’re trying to put to good use inside Lithium. So features like Late Static Binding, Namespaces, Anonymous Functions and closures are all being put to very good use within Lithium.

The Library namespace of Lithium comes with a host of additional classes that would be advantageous to many developers. There are the usual utility function to help with form validations, and implement a templating system, but there are also tools like Collections and Iterators — which are used in many places within the core code. There are also Socket and HTTP classes and even an example program that implements an IRC bot.

Another powerful feature of Lithium is their implementation of Filters, following the Aspect Oriented Programming model. This allows you to add a filter to an existing action being performed by the framework, modifying behavior on the fly. This is done without having to extend an existing class and override methods — something that would be impossible if not for the fact that they’re using PHP 5.3.

Lithium is not quite ready for prime time, unfortunately. They’re currently on version 0.7, with a projected 1.0 version some time in May, 2010. Even though it’s not quite finished, there is a suite of unit test code that is provided. Their goal is to have 85% or more test coverage on anything that is shipped. This promises to provide a pretty stable release.

Garrett and many of the other developers of Lithium have also worked in the past on the CakePHP framework. They split from that code base in order to develop a framework that takes advantages of the latest features of the PHP language.

And if you’re interested, slides from the presentation are available.

I’m going to be keeping an eye on this one since I like the idea of a framework that uses some of the latest features of the PHP language, rather than sticking to older versions of PHP like CakePHP does.

frameworks, php, Programming Languages

1 Comment

Deleting Unused Files

I had someone ask me recently whether or not it was important to delete unused files — like themes or plug-ins, from your WordPress install.

Extra themes and plug-ins that are sitting on your WordPress site really don’t do anything other than take up space. The code is not executed in any way. Only the currently active theme and any active plug-ins will be initialized by WordPress. This means that the extra files will not be slowing down the execution speed of your blog.

So, leaving those extra themes and plug-ins laying around won’t hurt anything. But they don’t do anything for you either. Having to page through dozens of themes or scrolling down the long list of plug-ins may make things a little slower for you. So if you don’t like the clutter of all those unused plug-ins laying around you should delete them. But if you’re worrying whether or not it’s slowing down your WordPress execution time, it won’t.

WordPress

No Comments

WordPress 2.9.2 Released

This is a new release to address a specific problem in WordPress:

Logged in users can see deleted posts that belong to other authors.

If you have untrusted users signed up on your blog and any sensitive posts in the trash, you should consider upgrading to version 2.9.2.

WordPress

No Comments

Permalinks

What is the best Permalink structure to use in WordPress?

There are probably quite a few different opinions in regards to the best permalink structure to use and some structures are going to be better from an SEO perspective than others.

The worst permalink structure to use is the default one. The default is yourdomain.com?p=#, where the # is the id number of the post. If you change nothing else in your WordPress configuration, you should change the permalink structure to something other than the default. This is because the URL that is generated for each post tells the search engine nothing about the content of the post. and a URL of mydomain.com?p=123 doesn’t contribute anything to informing the search engines about the content of your post.

On some hosts, the default is the only permalink structure that will work. This is because they don’t recognize the .htaccess file that WordPress uses to tell the web server how to map a different permalink structure to the post id. If your host does not support .htaccess files, and you have any interest at all in SEO — then you should look into changing hosts.

Personally, I use %category%/%postname%/. This is because I want the category of the post to be included in the URL of the post, which is one way of letting the search engines know that the category is important. I also have very few categories and they’re pretty narrowly focused. If you use a lot of different categories, this technique may not be as beneficial to you.

Some people like to include the date in the permalink, using something like %year%/%day%/%postname%/. While this isn’t bad, the search engines don’t really get anything out of it. Google doesn’t realize that the year is a year — it just looks like a number.

I’ve also seen comments that Google will rank a page better if the extension of the filename portion of the URL is .html, so they recommend using a permalink like %postname%.html. I don’t believe that a page ranks better with one extension over another. The search engines will take the entire URL and find keywords within it. So a URL of “top-10-best-web-hosts” vs. “top-10-best-web-hosts.html” will be almost the same, but the “html” is also included as a keyword in the second URL. Is the word “html” important when discussing the top 10 best web hosts? Probably not, so why include it in the URL? Does Google throw away the “html” portion of the URL? I don’t know. But there are lots of sites on the ‘net that have extensions like .php, .asp, .aspx, .pl or .cf and others and their content gets indexed by the search engines just fine. My conclusion is that the extension doesn’t add anything.

One of the reasons I like WordPress so much is it’s flexibility. And being able to change how a post’s URL will appear ranks very high as far as how the search engines look at the content of your site. So being able to change it to suit your purposes is just as important.

If you’re now convinced that you should change your permalink structure, what are the options? Here’s a list of the tokens that you can use in the permalink setting, as references from the WordPress Codex:

  • %year%
    The year of the post, four digits, for example 2010.
  • %monthnum%
    Month of the year, two digits, for example 05.
  • %day%
    Day of the month, two digits, for example 28.
  • %hour%
    Hour of the day that the post was written, two digits, for example 15.
  • %minute%
    Minute of the hour that the post was written, two digits, for example 43.
  • %second%
    Second of the minute that the post was written, two digits, for example 33.
  • %postname% – best!
    A sanitized version of the title of the post (post slug field on Edit Post/Page panel).
  • %post_id%
    The unique ID number of the post, for example 423.
  • %category% – better
    A sanitized version of the category name (category slug field on New/Edit Category panel).
  • %author% – good
    A sanitized version of the author name.

Which tags are the best to use? As mentioned before, all of the words that appear in the URL are used by the search engines to get an idea of the type of content for the page. So using tokens that help to describe the content is always best. The %day%, %hour%, %seconds%, %post_id%, etc. are just numbers and add little value. The %author% token on the other hand will add keywords, but remember how the search engines use these keywords. If the author name is important in categorizing the contents of the post then you can consider using it. But if it doesn’t add value you may be better off using something else.

Using something in addition to the %postname% token could be important if you also want to avoid collisions between your posts and pages. This may be another good argument for using the date as part of the permalink, as you’ll never have a collision between post and page names. But using any token at all will avoid the chance of a collision, so I always recommend to use another token that will add keywords, rather than one that will just add a number.

One final thing to note is the situation where you have more than one post with the same name. In these instances, WordPress will automatically change the permalink to avoid collisions. This is one reason why some people like using the date as part of the permalink. It is far less likely that you will have name collisions within the same month than over the entire life of your blog.

Exactly which permalink structure and combination of tokens will work best for you depends entirely on what you’re doing. As long as you’re using at least the %postname% token, you should be fine. The other tokens will help in narrowing the focus for your posts if that’s important to you.

SEO, WordPress

No Comments

Facebook Launches HipHop

Today, Facebook announced the release of “HipHop” — their php to C++ bridge.

While the php programming language makes it very fast and easy to create web sites, it’s performance it nowhere near as fast as compiled languages like C++. Or even pseudo-compiled languages like Java. So scaling a web site to handle thousands of page requests is a big problem.

I’ve often wondered how sites like Facebook manage to serve up these thousands of pages of dynamic content each second. Certainly adding more web servers is a solution, but those cost money. How does a smaller development house accomplish this sort of scaling without having to purchase dozens of server grade computers?

Facebook’s HipHop strives to accomplish this. What HipHop does is dynamically translate php code into C++. This means that the majority of code that is used to server up a page is running in native compiled C++, rather than an interpreted and loosely typed language like php. The result is a dramatic increase in speed and reduction in memory overhead — both of which translates into reduced server load, which means you need fewer servers.

The other major advantage is that your developers don’t necessarily have to learn C++, which is a much more difficult programming language than what many web developers are used to.

The best part about HipHop — Facebook is releasing it as Open Source. This means that the developer community will be able to look at the code, improve it, and add new features. This almost always means more support and continued new releases. All good things.

For more information on HipHop, refer to Facebook’s announcement of HipHop.

I’ll be keeping an eye on this new technology.

HipHop, php, Programming Languages

No Comments