Doctrine Session Driver for Kohana 3 [Updated Feb 21 2011]

Posted October 14th, 2010 (Updated 29 Oct 2011) in Database, PHP

Here’s my second Doctrine 1.2 driver for Kohana 3, this time for the Session class. I wrote this because I don’t particularly like the Kohana Database or ORM classes (that or I just don’t want to take the time to learn them!) and it’s released under a creative commons v3 licence So here it is. Enjoy!

Kohana 3 Doctrine Session Driver 1.02 See here for details

UPDATE 22 Oct 2010: Bugfix release – should actually work now :)
UPDATE 03 Jan 2011: Fixed rare bug in DB cleaning function.
UPDATE 21 Feb 2011: New module at a new home! See here for details

Read More »

Deleting a Google Calendar with PHP

Posted October 13th, 2010 (Updated 29 Oct 2011) in PHP

I’ve recently started looking at the Google Calendar Data API for PHP for use in an upcoming project. It uses Zend Framework which has a pretty nice library complete with documentation here allowing for just about every operation I required…except deleting calendars (which is a bit strange, considering you’re able to create them with the API). This seems to be a limitation with version 1.0 of the API. Version 2 allows for deletion of calendars however there’s no documentation PHP implementation yet. After a long night of researching and hair pulling I’ve finally managed to come up with a working script provided.

EDIT – Now working with Zend Framework!

Read More »

Accessing Google Docs Spreadsheets in Firefox 4 Beta

Posted October 9th, 2010 (Updated 29 Oct 2011) in Uncategorized

I installed firefox-4.0 (currently 4.0b8pre) on Ubuntu Maverick RC earlier today and all was going fine and dandy until I had to open a Google Docs spreadsheet. I’d receive a message stating:

The <strong>bad news</strong> is that Google Docs has just encountered an error.
The <strong>good news</strong> is that you've helped us find a bug, which we are now looking into.
We apologize for any inconvenience this has caused you.
In the meantime, if you'd like updates on this and other issues, try visiting the Google Docs Help Forum.
<strong>Sorry, and thanks for your help!</strong>
- The Google Docs Team

I checked documents and they seemed to be fine. It turns out this is an issue with Google not recognising FF4′s user agent string. The easiest way to solve this issue is to type about:config into the address bar and set


to true.

Read More »

“Discovery Failed” with Zend OpenID

Posted October 2nd, 2010 (Updated 29 Oct 2011) in PHP

A very quick post for any of you poor souls suffering the dreaded ‘Discovery Failed’ message in Zend_OpenID_Consumer when trying to connect to Google – see this comment on Stack Overflow for the solution you’re looking for. Hopefully this’ll save you some time hunting around on the web for it.

Read More »

Resized Image URLs with Kohana 3

Posted August 31st, 2010 (Updated 29 Oct 2011) in PHP

Have you ever wanted to generate a resized version of an image just using a HTML image tag and not worrying about entering large chunks of resizing code or storing cached images of various sizes? Today’s tutorial will show you exactly how to do that with Kohana 3. In this tutorial I will teach how to use the URL to load a dynamically generated, resized image.

The trickiest concept to grasp in this tutorial are the URL segments. Imagine your site was located at and you were browsing to this page In this instance, ‘segment 1′ would be archive, segment 2 posts and segment 3 my-post. Segments are split with the / character. In Kohana, URL segments take the following form: controller/method/method_arg_1/method_arg_2/etc…

Read More »

PHPExcel Module for Kohana 3

Posted July 31st, 2010 (Updated 29 Oct 2011) in PHP

As with any project involving generation of .xlsx spreadsheets there’s only really one way to go – PHPExcel. This amazing piece of software boasts a large feature set – allowing quick and (relative) painless generation of XLS, XLSX, PDF, and CSV to name a few as well as importing of the same sans PDF. I recently had to integrate PHPExcel into Kohana 3 so I figured I’d take the time to post the how-to and hopefully make your lives that little bit easier. In addition I’ve included a quick and dirty Spreadsheet class to make XLSX generation that bit faster.

Read More »

Integrating Swift Mailer Into Kohana 3

Posted June 29th, 2010 (Updated 29 Oct 2011) in PHP

This is quite possibly one of the simplest integrations in Doctrine history (It’s a 1 liner, folks). The following is a short tutorial on how to create a SwiftMailer module for Kohana 3

Create the following files/folders:

Inside /modules/swiftmailer/classes/ drop the official latest build of Swift Mailer.

Enter the following into init.php.

	require Kohana::find_file('classes', 'Swift-4.0.6/lib/swift_required');

There. Wasn’t that easy? Remember to enable the module by adding it to your bootstrap.php file!

Read More »

Kohana 3 Multiple Scripts and Styles Extension

Posted June 27th, 2010 (Updated 29 Oct 2011) in PHP

In Kohana 2, html::script() and html::stylesheet() accepted an array or string as their first arguments. This allowed you to easily add multiple scripts and styles simultaneously without needing to write several lines of redundant code. Kohana 3 has removed this useful ability so I thought I’d write a very quick extension to add the feature back in. The following script adds HTML::scripts() and HTML::styles() (As Kohana 3 slightly renamed their functions to HTML::script() and HTML::style() respectively).

Simply add the following file html.php to your /classes directory:

<?php defined('SYSPATH') or die('No direct script access.');
class HTML extends Kohana_HTML {
	public static function scripts(array $scripts, $attributes=array(), $index = FALSE)
		$response = '';
		//Data sanitisation
		$index = $index ? TRUE : false;
		if ( !is_array($attributes) ) $attributes = array();
		foreach ( $scripts as $script )
			$response .= html::script($script, $attributes, $index);
		return $response;
	public static function styles(array $styles, $attributes=array(), $index = FALSE)
		$response = '';
		//Data sanitisation
		$index = $index ? TRUE : false;
		if ( !is_array($attributes) ) $attributes = array();
		foreach ( $styles as $style )
			$response .= html::style($style, $attributes, $index);
		return $response;

Download: html.php


echo HTML::styles(array(
echo HTML::scripts(array(

Note: Both functions accept the latter 2 parameters available in Kohana 3 HTML::scripts() and HTML::styles(). If used, these arguments will be applied to every element in the first arguments array.

Read More »

Doctrine Driver for Kohana Auth Module [Updated 21 Feb 2011]

Posted June 21st, 2010 (Updated 29 Oct 2011) in Database, PHP

It’s probably become apparent by now that I like Doctrine. It’s quick, it’s easy and it works with everything. So here’s a Doctrine driver for the Kohana Auth module, allowing you to use Doctrine instead of Kohanas integrated ORM.

Download: Kohana Auth Doctrine Driver 1.03 here

Installation instructions:
Unzip the module to your /modules folder.
Enable the module by adding

'auth_doctrine' => MODPATH.'auth_doctrine',  // Doctrine driver for Auth module

to the modules array in the following file:
Kohana 3:/bootstrap.php
Kohana 2: /config/config.php

UPDATE Jul 15 2010: Fixed incorrect user login bug. Please redownload
UPDATE Dec 22 2010: Fixed ‘remember’ session bug.
UPDATE Jan 3 2011: Fixed bug if calling Auth::instance()->logged_in(‘role_name’). Thanks to freenode #doctrine user SirFunk for this one – good catch!
Update Feb 21 2011: New module at a new home! See here for details

Read More »

Integrating Doctrine Into Kohana 3 [Updated 21 Feb 2011]

Posted June 21st, 2010 (Updated 22 May 2014) in Database, PHP

Update Feb 21 2011: New module at a new home! See here for details

Upon the release of Kohana 3, one of the first things I wanted to do was install Doctrine. The following is a short tutorial on how to do; and keeping with Kohanas modular style, it will be placed in its own reusable module. Time to begin.

Create the following files/folder:

Inside /modules/doctrine/classes/doctrine drop the official latest build (see here) of Doctrine such that Doctrines CHANGELOG, COPYRIGHT etc files etc are inside.

Enter the following into init.php. Note – this may not be the optimal bootstrap file – feel free to tweak to your hearts content.

Read More »

Page 11 of 14« First...910111213...Last »