Archive for September, 2010

Kohana 2.x kotidy – Using the Tidy library to clean up Kohana’s HTML output

In a quick followup to yesterday’s building and releasing autoasset, I’ve created another module to do something simple and portable for Kohana 2.x. This module, kotidy, uses the PHP Tidy library to clean up the HTML output immediately prior to display. Even though the HTML is not seen by the end user, I find myself OCD about this kind of stuff and want to know that my source code is clean, even if most people will never see it.

Just like autoasset, kotidy uses the Event system to hook a basic function in place to use the tidy library to clean up the output. Other than adding this module to your module list in the main config file, no work is required on your part, unless you want to customize the config data being sent to Tidy::parseString(), of course.

Download Kohana 2.x – kotidy

, ,

No Comments

Kohana 2.x Autoasset – Automatically include relevant javascript, css and more

I’ve set up about a half dozen Kohana 2.x sites now, and one problem that I constantly run into is including javascript / css based on the controller and method for the current page. For instance, if you go to “/user/view/1″ on a Kohana site, I would like to automatically include “/javascript/user.js” or “/javascript/user/view.js”, if the files exist.

To solve this problem, I created an autoasset module for Kohana 2.x. It will not work on Kohana 3.x due to the removal of events and hooks. To use autoasset, simply load it like you would any other module, and then go into the config file and specify which kinds of assets to load. Just input the directory that these assets are stored in, the file extension, and a callback to use when rendering. I put in example entries for javascript and css as a demonstration. You can then render the autoloaded assets by calling autoasset::render(); where you want to include the assets, such as the html head tag.

On a similar note, modules like this are one of the main reasons why I am launching I think Kohana 2.x is a fantastic framework, and if a large community arose to provide modules that are just generally useful, then Kohana 2.x could really shine.

Download Kohana 2.x Autoasset

, ,

1 Comment

Kohana 2.3 community

I’ve been a Kohana user for about a year now, and every major update pleases me less than the last. I’m considering starting a community dedicated to Kohana 2.3, built around maintaining documentation (since the official site already pulled the Doxygen docs, how long until they pull the documentation wiki?), creating new modules and generally working on preserving the Kohana 2.3 legacy. Would anyone be interested in being a part of this community?

I’d like to stress that I am in no way trying to insult the developers and maintainers of Kohana through this project. Their work has been absolutely amazing, but just as they forked from CodeIgnitor when they felt it was no longer serving their needs as developers, so now am I feeling that Kohana no longer serves my needs as a developer.

I’m setting the project up at I’ll begin adding some functionality such as forums and module hosting / rating.


1 Comment

The joy of tech support

This series of emails happened about 6 weeks ago, but I wanted to store it here for posterity, because it amuses me and I can do that.

I had recently obtained dedicated hosting for a work project and was having some bizarre issues with .php files throwing a server error, even if the file was a single “phpinfo();” command, so I contacted tech support.

One remaining problem that I am encountering is getting PHP scripts executing on the site. I have a simple file, just running phpinfo(), but it is causing a server error for reasons I have not been able to figure out. I have checked file permissions, recreated the account a few times with all features enabled, and checked PHPMyAdmin to ensure PHP does work on this server, but nothing seems to be working to get this file to work. Is there a setting somewhere, in either WHM or cPanel, that I am missing to enable PHP on this account?

The response was fairly speed, but utterly bizarre.


Please try it now. I commented out a line in your .htaccess file and it’s working now. Let us know if you need any further assistance.

How could my .htaccess file, which was blank during most of these errors, have been a problem? I inquired.

Did you do anything besides that? I added that line after I sent you the support request. When I sent you the support request, the only file on the server was a simple phpinfo() file. Afterwards, I began toying around with the Apache handlers, both in cPanel and in the .htaccess, with nothing working.

Ah, he forgot to mention something.

I did re-compile PHP on the server for good measure since the file should have worked, but the error log was still showing an issue with the .htaccess file so I commented out the handler line and it started working. Please let us know if you need any further assistance.


No Comments