A potpourri of Web Developmemt, Linux, and Windows tidbits and observations

PHP Framework Benchmarks

Posted by dale | PHP Frameworks | Monday 31 May 2010 5:37 pm

We’re all curious about the speed of PHP Frameworks. The only way to judge this is with benchmark tests, and each benchmark test has a multitude of variables, is their caching in use or not, does the test include database performance, for example. A comparison from one benchmark to another is almost impossible, more a subjective exercise, than one of scientific comparison. Thus, I will only subjectively review relative performance of one framework against the others, in other words, this is my opinion, take it with a grain of salt.

Having said that, I looked at as many benchmarks as I could find on the Internet to compare. There were over 18 PHP Framework benchmarks done by others on the Internet. I threw out some, for one reason or another, and got down to the 18 benchmarks I used.

One problem was that only a small set of frameworks were selected for testing in each benchmark.  However, by putting the benchmark results in a spreadsheet, and then giving those results a consistent relative weight across all the benchmarks, and then averaging these relative weights across the 18 benchmarks, I was able to come up with a reasonable performance comparison for all but two of the frameworks, which had no performance benchmarks: Fuse, and Qcodo.  Akelos had only one benchmark, so its results are highly suspect. The number in parenthesis is the number of benchmarks that I found including that framework, and thus the more reliable the information.

In the blindly, super fast, but not enough tests to verify, category is: DooPHP (2). DooPHP did their own benchmark, so the results are questionable. They claim to be “the fastest PHP framework.” DooPHP needs further testing, but it looks like the fastest framework of the group.

In the superfast category, with enough tests to verify is: Codeigniter (15), Kohana (4), and Yii (8). These three are very close in results, and a step above the next group. I saw tests where each one was rated faster than the other, but only by the slimest of margins. Generally, everyone tests against Codeigniter, since it’s been around for awhile, and Codeigniter is usually a hair better than Kohana, and Yii, but it’s pretty close. Take your pick.

In the middle ground we have: Symfony2 (3), Solar (2), Akelos (1), and Zend (9). Symfony 2 looks like a significant performance enhancement over Symfony 1.2.4 (7), but was not quite up to the super fast group.

And the bottom of the pile is Cake (15). Cake was everyone’s “favorite to test against, and bash framework,” and consistently was the worse performing framework in all 15 benchmarks.

Without further ado, here is my relative performance rankings, based on the above 18 benchmarks, with ten being the fastest followed by the other frameworks approximate relative performance results.

  • 10.00 DooPhp
  • 7.86 Codeigniter
  • 7.75 Kohana
  • 7.04 Yii
  • 6.63 Symfony2
  • 6.00 Solar
  • 5.50 Akelos
  • 4.78 Zend
  • 2.79 Symfony1.4.2
  • 2.03 Cake

Codeigniter still supports PHP4, however Ellis Labs is working on Codeigniter 2 with Codeigniter 2.1 is set to be PHP5 only. The trouble with futures is Codeigniter is notoriously slow with its releases, which is why Kohana came into existence in the first place, as a fork of Codeigniter. We don’t know how a new release will affect overall performance of the framework has evidenced by what happen with Symfony.

Kohana has just released a 3.0 version, that is not quite ready for prime time more in my next article.

Yii has much improved documentation, since I last looked at them.

Symfony 2 was quite a performance boost over one and has good documentation.

Akelos is a Rails clone and supports both PHP4 and PHP5 with code generation.

Zend has a rich library, and is sponsored by the folks who make PHP.

Cake has a strong user community.

I will review each of these framework’s features in my next article, see you then.

PHP Frameworks – A Selection Criteria

Posted by dale | PHP Frameworks | Friday 28 May 2010 11:38 am

We talked about what a framework is and why you’d want to use a framework. Since there are over 70 PHP Frameworks, how do you select one from another? What are some of the things you ought to consider?

Frameworks try to be unique. There is no reason a developer, or group of developers would want to write, “just another framework.” They would take the time to write a framework only if they thought they had something unique to offer technically that no one else had done before. Isn’t it that way with all products, each one is different, maybe slightly so, but different and unique.

Having said that, it might surprise you to know, that technical features are not the main criteria I use for picking one framework over another. Sure it matters, but there are additional reasons you should consider, that to me, weigh a tad more.

Number one on my list is documentation. Each framework has its own unique syntax, unique naming conventions, unique methods of organization, and unique methods of working within the framework to achieve a finished web site. It’s not enough just to release the source code, and be done with the project. How do you use the framework, what functions and classes are available for use? The only way to know is through documentation. The developers have to tell us.

What constitutes good documentation? Things I like are an introduction to a section of content telling in general terms what that section is about, and how it is laid out, followed by examples of syntax and usage. Ideally, a snippet of code that accomplishes a small task using the function or class. A good API where an index of functionality is listed separately is nice, and finally some tutorials, traditionally these consist of “Hello World” and “the 10 minute blog,” showing you how to put an application together. Video tutorials are just icing on the cake. And the best of all worlds, is when that framework has a published book, showing that someone cared enough about the framework to write a book about their passion with the framework.

Next is a combination of good code and documentation. I want the framework to be easy to install with clear cut installation instructions on multiple platforms. The code should come up and run, or if configuration is needed for the system, the documentation should walk us very slowly through the process. An installation screen that checks system requirements with a unit test gives me assurance that I can run the framework and all I need to work at now is configuration. Once configured the framework ought to show an introductory code example to the front of the screen as a jumping off point and introduction to the framework.

An active forum is the next thing I check. How many people are developing with the framework? When was the last posting in the forum? Hopefully, it was within the current month. I got excited about one of the frameworks I hadn’t looked at before and when I checked the forum, the last posting was two years ago, needless to say I didn’t investigate much further. What happens when you run into a technical problem in your development, you want somewhere to turn to ask a technical question. The larger the user community the more secure that I feel that the framework won’t go the way of other dead frameworks of the past.

It would be nice to have a group of developers that work on the framework, more than one person developing means faster bug fixes, more versions, and better features and functionality.

I like to see a history of consistent versions, a version history, that shows a continual effort to improve the framework over time. And consistent in the sense of continuity, that the framework is not getting ripped up with a new architecture with each new version, which implies having to relearn the framework all over again.

Finally, I want quick software. I don’t want a lot of bloat added to my code by the framework. I call this a lightness in the code and the way its used. Speed is a good measure of this. Is the framework quick.

And now to some PHP technicals. I want a framework that incorporates the latest technologies, and is up to date with what’s going on currently in the software development world. With PHP, that means object oriented. The framework has to be PHP 5 based only. The trouble with those that do PHP4 and PHP5 is there are allowances made to incorporate the old technology which to me distracts from the use of the framework.

And I finished with some of the things I talked about in the introductory article. Good security, a good autoloader, an intuitive file architecture using the MVC model. I like to see an ORM, or Object Relational Model, that speeds database SQL integration with PHP objects.

The above list of criteria, cuts that list of 70 down to only a few frameworks, I’ll give you some opinions on the current state of some of these frameworks in my next posting.

PHP Frameworks – An Introduction

Posted by dale | PHP Frameworks | Thursday 27 May 2010 1:12 pm

We’ve seen an explosion in development tools for the Internet in recent years. It seems like every developer has a better idea, and each implementation and language has its advocates on the best way to populate a web page.

In the world of the PHP developer, we’ve seen a flood of PHP Frameworks. If you Google the wiki on PHP Frameworks you’ll see some 70 PHP Frameworks.

Why this proliferation of PHP frameworks, and why use a framework? Let me start with an example, I completed a web project last year where I used XHTML, CSS, PHP, MySQL, and jQuery, and that’s it, the base tools, with out any frameworks or utility programs. This project was a complex, object-oriented, accounting and reporting application. It took about six months to complete version one. I found myself running into several problems during the process, where I thought there had to be a better way.

Here’s what I wanted. A better way to ensure the site was secure from hacking. When your developing a site, security seems to be an afterthought to getting the application up and running. There should be a way to incorporate secure techniques automatically throughout the site.

I can’t tell you what a pain loading required and interconnecting classes with their proper locations, and doing PHP includes and requires, on every web page was. A good part of my debugging time was taken up with making sure classes and data was visible when needed and in scope. Include_once gave me some debugging problems. My thought was there should be a better way to load classes and files through out the site, I did put in an autoloader, so I didn’t have to list every class on a page, but it would have been nice if that was available out of the box.

Although I used an MVC layout for the site. During the course of development, some other folders and helper utilities were incorporated into the site, in what I want to say, was a non-standard way, and done more for expediency. It would be nice if a site structure was predefined that would account for the different type of utilities you’d need to complete a site. This would also speed all future development as I would know where things went right from the start.

Another area that took time was keeping track of session data and variables and when and where they were in scope, or no longer available, improved session and cookie handling would have been nice. Validating forms required helper utilities that were used on multiple pages of the site. The site was done in English, it would be nice, if I knew the site was easily transferable to any language.

I wrote my own MySQL classes and class managers for each of my database tables. Essentially, along with my own SQL queries for each table needed. This was a rudimentary Object Relational Model, that translated the SQL to PHP objects. It would have been nice if this ORM would be available up front and was richer with more functionality.

Thus we come to a definition of a framework. A framework is a packaged set of utilities along with a file structure, naming conventions, methods, and ways of working, to make web development more secure, easier, and help developers speed up the development of web applications. The idea is you drop in the framework at the start of the project, and use the same framework on every web application you develop. The result is an improved, more secure, site, and with much less time spent in development.

Sounds great, but there’s a problem. It turns out that every developer who has coded a web site has a better idea on what a good framework should be, and how the code should work. Developers want to put together a framework that they want to use, and so they develop one, than decide that other developers would like their framework too, and put it out in the world. Thus we have some 70 PHP frameworks out there.

Thus the problems with frameworks. Until you standardize on a framework, you have to go through all the frameworks available to see which one is best suited for the way you want to and like to work. You find yourself constantly looking at frameworks, and the latest framework, to see if that model is better suited to your development, and has a better set of utilities, than your last framework. This is a major time suck. You need a method to quickly sort through the field and narrow the list. I’ll talk about what you want and need to look out for in a framework in my next post.

Saving your Windows Data with an Ubuntu CD

Posted by dale | Windows | Sunday 23 May 2010 3:39 am

I’ve found I get angriest when my expectations get altered. I think I”m going to have a nice leisurely weekend, and my computer loses a hard drive. Losing a hard drive is a slow, gnawing, exasperating pain. If you have data that you need like company books, tax or investment information and you lose that, there is a good chance that you’ve got addtional work to restore that data, or even more painful, recreate it from paper records.

It takes a good 12 hours or more to recover, reformatting or replacing disk drives, reloading the operating system, the drivers, your application software, and hopefully, your backed up data. Most folks, chuck it all, and buy a new computer, but even that takes time to shop, and you still need to reload applications and data. Then there is the expense of buying a new computer, or disk drive, or application software.

I lost my hard drive, because somehow my boot sector got corrupted. I found there are work arounds to repairing boot sectors, but a good majority of the time, you end up reformatting your disk and losing your data. I find myself getting more and more mad at Microsoft’s stupid, difficult to understand what’s going on menu choices, or menu choices that you want to be there, but you can’t get there unless you reformat the drive. I get irritated, because there could have been an easier way of doing all this.

You wonder why it takes so long, I counted over 40 application programs I use regularly on Windows. All of them need to be reloaded. Of those 40, eight of them are there only for Windows security. I’m talking anti-virus, firewall, disk cleaners, registry checkers, and malware removers. I trust them more that I do Windows security updates, which to me, just slow down my computer.

If you have ever considered Ubuntu, or any of the Linux distros, now’s the time that they come to mind. And actually, because they came to mind, I was able to save all my data before having to blow it all away. Here’s a reason to make yourself an Ubuntu boot disk, and try Ubuntu out, before your next disk problem.

Ubuntu sets up its boot disk so you can boot from the disk without altering the contents of your computer. This was a very smart move on their part. If you’d like to try their operating system environment without messing up your computer, make yourself an Ubuntu CD, load the disk in your CD drive and reboot. Up comes Ubuntu, without accessing your hard drive.

What’s nice about booting Ubuntu from disk is it has a file like explorer window that shows you the contents of your hard drive with all your files and folders. It is a full fledged file explorer, and you can copy files from one disk to another. That’s right, even though your running Ubuntu, you can copy your Windows files. There’s a good chance, even though, Windows cannot access your corrupted disk files, Ubuntu can. In my case, since the problem was in my boot sector, there was nothing wrong with any other portion of my disk and I had access to all my files.

I happen to have a 400Gb external USB drive that I use for just this type of backup situation. If you want you can take your entire drive to your external drive and your data is safe, but that’s probably overkill, go get your data. If you don’t have a large external USB drive, I recommend you purchase one. You’ll be surprised how handy they are when you need them.

And if you’d like to make yourself an Ubuntu boot CD, not DVD, download the Ubuntu desktop from the web site. It comes down as an iso file, download an isoburner, InfraRecorder, burn your CD. Try it out, you may find that Ubuntu is a very nice operating system. If you like to know a bit more about creating an Ubuntu cd, I’ve written a previous article on this topic, where I’ve discussed how to do this in detail and why you want a CD instead of a DVD.

Removing Deleted Files from your Git Working Directory

Posted by dale | Version Control | Sunday 16 May 2010 2:44 pm

You update a module that deletes a bunch of files.  An hour later, you decide to combine two files into one, and delete the other file.  At the end of the day, you decide to do a git commit.

You run git status and a bunch of deleted files show up.  Darn, well I’ll do a “git add .” and try to commit.  The deleted files don’t go away, and they don’t stage to commit.

Git add . does not move the file out of the working directory

How do you get these deleted files out of your working directory, so when you run “git status,” you get that blessed “nothing to commit (working directory clean)” message, we all know and love?

The same problem shown in the Git Gui

First, so we’re on the same page, let’s do some quick definitions.

The git “directory” (.git) is where git stores all the information about your project, all the history, all the commits, and all the meta information about your repository, and what files and folders are included in that repository.  There is only one “.git directory” per repository.

Your “working directory” is where Git keeps track of all the content changes to your files and folder as your working: all your new files, deleted files, and modified files, since your last commit.  It is created when you create a branch,  and changes as you do commits.  Each branch has its own “working directory” which can be, but doesn’t have to be, different for each branch.

The git “index” is where you keep track of changes you want to make to your next commit.  When you do a “git add,” you stage the files in your working directory to your “index” in preparation to commit.

If you “git add” all the file changes in your working directory to the index, the working directory is clean.  When you commit, git makes the commit match the index, and clears the index, and we get the “nothing to commit (working directory clean)” message when asking for a git status.

The problem with removing files or folders, as your working, is that these changes are recorded in your working directory, but a “git add .” cannot put the deleted files in the “index,” because they don’t exist anymore, you deleted them.  But they still show up in your working directory, when you run “git status,” because they have not been cleared out of your git “working directory.”  Seems like a cache 22.  You can’t add them to your index to commit the deletion, and you can’t get the deleted files out of your “working directory,” since they are different from your last commit.  Are we doomed to have a long list of deleted files?  You know better.

First, let’s use git add like we normally do with a switch.

“git add -u”    This is the same as “git add –update”

Git add -u adds deleted file to the index ready for commit

The -u says look at the index, and only add files from your working directory that are in the index.  Any files with modified content in the index will be updated, and any files that have been removed in the working directory, will be put in the index for removal in the next commit.

Git add -u result shown in the Git Gui

Git commit removes the deleted file and we have a clean status

This is what we want, when we do a commit the deleted files go away, but there’s a catch.  The -u will work, but new files in the working directory will not be added, since this is an update.  You still have to run “git add .” to get the new files.  Use -u when you don’t want to commit new changes yet, but want to move deleted files to your index for the next commit.

Let’s simplify.  Let’s use:

“git add -A”    This is the same as using “git add –all”

Git add -A adds the deleted file and the new file to the index

This is like “git add -u,” however it matches files in your working directory, and your index.  That means that it will add new files, as well as updating modified content in your index, and remove files that are no longer in the working directory.  Note, there is no “git add -a”  Linux is case sensitive, the “a” doesn’t work, the “A” does.

Git gui after a "git add -A"

This is the best of both worlds and the recommended way to clear those deletes from your working directory.

One last thought, if you use “git rm <file name>” when you remove a file, this removes the file from both your working directory, and updates your index, ready for commit.   

Git rm adds the deleted file directly to the index, without an add

Git rm is not always possible when your in the middle of developing, it’s just not convenient.  “git add -A” is what you want.

Next Page »