Kohana is one of the fastest PHP MVC frameworks around, forking from CodeIgniter a few years ago but fully optimized for PHP v5. Although it has a solid pedigree and is used by an ever-growing number of top sites, it suffers from a lack of documentation and a comparatively small community of developers. Packt’s latest book, Kohana 3.0 Beginner’s Guide, aims to fill this void and provide new developers with a Kohana primer.

I also acted as a technical reviewer for the book.

My PHP Background

I started programming with PHP v3 back in the late 90s and slowly upgraded my skills as the language developed into the behemoth it is today. A few years ago I almost wrote my own MVC framework.

I had a number of core classes that I’d bring to every project; database abstraction, error handling, logging, form handling and security components. They were a little disconnected and I wanted to bring them together, along with some JavaScript and CSS asset management but I also wanted to bring in URI routing for SEO/SEM reasons. I’d also experimented with templating in PHP but never wanted to learn a templating language on top of everything else. In the end, I developed my own templating system that was very much like Mustache today.

Therefore, I embarked on writing my own framework. I just didn’t know it was called a framework or that there were already lots of them around.

Google led me to the MVC pattern and this journey of enlightenment led me to CodeIgniter, Symfony, CakePHP and Zend. A few hours of Googling, reading reviews, downloading and inspecting the codebases led me to one place — CodeIgniter.

I liked the company driving the development this appeared to give it sustainability and direction. The code was clean and well-documented but it was also logical and the community was strong and had a number of extensions I could quickly leverage. Most importantly, it was fast; lightning fast. It added very little overhead to the pure PHP code and considering that PHP is interpreted rather than compiled, I didn’t want to add any more lag to the language. I also wanted a framework that would scale as I didn’t want to develop a site, publish it and then re-factor and remove the framework in the future because it was too fat. I needed lightweight, production ready and scalable.

CodeIgniter did everything I wanted, it replaced all of my homegrown classes and gave me more out-of-the-box plus it had potential for growth. So I started to learn it and how it took this MVC-thing and split the code into logical chunks. It felt like developer heaven; just a few lines of elegant code to achieve something complex.

And then I hit a few niggles. Niggles that were present in PHP v4.3 but not PHP v5.0. I wanted to use the new PHP way of doing things, not stick to the tried and tested approach. PHP v4.3 was also on the way out, more and more people were switching to v5, even my local development environment was running v5 by default. Maybe I needed to embrace the change and the future rather than sticking to the past.

My first CodeIgniter project never saw the light of day. It was usurped by Kohana v2.3.

Kohana

Kohana 2.3 wasn’t a like-for-like replacement but it reduced the amount of code I had to write. The big problem with Kohana was that it took me hours to write one line of code due to a lack of documentation and examples. In the end I started collecting links around the Internet and sifting through what applied to 2.3 and what didn’t. It was deeply frustrating. I’d copy an example from one site, run it and hit multiple errors due to changes in the methods from 2.1 to 2.2 or 2.2 to 2.3. The only way to debug these examples was to read the Kohana source code — something that everybody on the forums would berate newbies about all the time. What sort of a framework expects developers to read the source code? I’m sure PHP wouldn’t be where it is if developers were told to read the source code. Part of PHP’s success is the excellent documentation, the contributed notes and the multiple examples on the official site and around the Internet.

However, I persevered and I started to beat the learning curve into submission, slowly. I got used to how the development team thought and I became more proficient at using FIND ALL to look through the source code. A few magic methods caught me out but they slowly phased these out as Kohana developed.

And then Kohana 3.0 was released but it had a different feel. It seemed like there was a commitment to documenting the framework and a commitment to opening up the framework to lesser PHP demi-Gods such as myself. I signed up and embraced the change, to the change.

My Involvement in the Book

Packt tracked me down through some of my Kohana postings on the Internet and asked me if I’d like to act as a technical reviewer. This was my opportunity to help out the Kohana project and help to shape this book and hopefully widen the adoption of this framework. Here was my opportunity to contribute to the project.

I asked The Wife if she minded me stealing a few hours from our family life to do this, for free. She agreed.

It took about two months for me to review the chapters one-by-one and provide feedback for the author and editorial team. During this time Kohana developed from 3.0 to 3.1 which made the book reviewing and writing more difficult. I guess this is always the problem with publishing books on open source code that changes rapidly, it’s a challenge.

The Book

The book takes a PHP programmer through the basics of Kohana and assumes they know nothing about MVC frameworks. It guides the developer from installation all the way through to final deployment into production using an example application. All of the core Kohana features are covered in the book from the HMVC pattern, URI routing, database queries, the ORM, troubleshooting applications and securing Kohana-based sites.

I personally think Jason Straughan has done a great job of weaving an educational path through Kohana that will quickly get any Kohana developer up-to-speed.

The Future

As I was reviewing the book I kept on thinking of other topics that should be explored in more detail, or that there were other more advanced techniques that were worthy of mentioning but I had to temper them with the book’s audience. I’m currently waiting for my official copy to arrive but I intend to write some blog articles based on the book, extending some of these ideas but also bringing them up-to-date with the current release of Kohana.

So watch this space and I’ll start to create an addendum for this book based on where we’re at today in Kohana-land.

In the meantime I look forward to a more advanced guide to Kohana being published but with such a fast-moving target it could be impossible to write and publish. Good luck Packt!

Related posts:

  1. PageLines Platform Pro
Tagged with:
 

Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...