In this tutorial we will cover how to build a module from scratch in Kohana 3. If you aren’t familiar with the Kohana framework then I recommend you read the beginners introduction to Kohana.
The Plan
We will be building a module that replaces Kohana’s own view layer (Kohana_View). It will use the PHP template library Twig. We want our own view layer to be API compatible with Kohana’s view layer. This will ensure that other modules work out of the box and that the only code the developer will need to alter in their application are the templates (so that they are Twig compatible). No code in any controller will need to be modified.
Because Kohana follows HMVC (see beginners introduction to Kohana) we will be calling our class View. This means that all calls in the application to the class of View will be to the View class in our module, not Kohana’s own View class.
Directory Structure

Enabling The Module
The name of any Kohana module is the same name as the directory inside the modules directory. So in this case it is twig. To activate any module, we must add it…
App Engine 1.4.0
Two big changes in the latest Google App Engine release have been the new Channel API and the new 10 minute limit for background processing with a new Task Queue API. Both of these have been highly requested features for some time.
The Channel API creates a persistent connection between your application and Google servers, allowing your application to send messages to JavaScript clients in real time without the use of polling. This is useful for applications designed to update users about new information immediately. – Google
Expect to see the Channel API used for chat applications and real time games. The new Task Queue API allows developers to easily set up long running task jobs. Prior to GAE 1.4.0, scripts could run for a maximum of 30 seconds before they were terminated. Now scripts (using the Task Queue API) can run for a maximum of 10 minutes so data manipulations will be able to be performed on App Engine rather than on an external server.
PHP Maintenance Release
PHP 5.3.4 and 5.2.15 are now available. Both contain numerous bug and security fixes from their previous versions. Support for the 5.2 line is…
This is a brief introduction into the Kohana framework. The next two tutorials will cover how to build a blog in Kohana.
Installation
Installing Kohana is very straight forward, just download the latest stable version of Kohana and unzip it. No need to mess around with yaml or xml files like other frameworks. Navigating to the directory on your web server should give you a page similar to…

Filesystem
The filesystem plays a big part in the operation of the Kohana framework. Kohana follows the HMVC pattern (hierarchical model view controller). This means that the same filesystem structure exists at multiple locations in the framework. The following directories exist in the application, system and in all module directories:
- classes
- config
- i18n
- messages
- tests
When calling a class in Kohana, the autoloader checks if the class exists first in application/classes/ , then in each of the installed modules, classes subdirectory and finally in system/classes/. If the file cannot be found then an exception is thrown. Kohana follows the Zend_Class_Naming style. For example, if you instantiated a class named Hello_World, Kohana would look at each of the following locations in this order. If it finds that…
Lets make a [javascript] framework
Alex Young has been writing a series of articles detailing how to create your own javascript framework. So far he has covered DOM selectors, events, AJAX, animation, chained APIs (similar to jQuery) and testing. He goes into great detail regarding each of the components and provides clear code snippets. This is a great resource for anyone who understands the fundamentals of Javascript and would like to learn how frameworks are made. I personally found the animation section very interesting as there isn’t a whole lot of content detailing about how animations work on the web. All of the framework code is open source on github.
You can read the series online or download it in several different eBook formats from the DailyJS blog.
Symfony PR4 released
Symfony PR4 is most likely the last preview release before Symfony2 hits beta and that it comes with all features intended to be in the final release of Symfony2.
The latest pre release of Symfony2 includes code and documentation support for:
The HTTP caching feature of Symfony2 is interesting as none of…
October 25th, 2010 / By Adit Gupta /
1 comment
A couple of weeks ago, Ajax.org released a new IDE for Javascripters known as Cloud9. It’s an open source project built on Node.js. In case you don’t know, Node.js is an implementation of Server Side JavaScript (SSJS) and is now actively being used for SSJS development. Since Cloud9 IDE is built on top of Node.js, it has an integrated debugger for Node.JS applications. In this article we’ll be taking a look at various features of Cloud9 such as those mentioned above, but for now let’s begin with installation.
Installation
Installation is very simple provided you’re familiar with the terminal. There are three ways to install Cloud9:
1. If you’ve Git installed on your system then you can get the code repository directly from Github. Just enter the following command in your terminal:
git clone git://github.com/ajaxorg/cloud9.git

After Git checkout, enter the following command to install all the submodules and run the IDE:
bin/cloud9.sh

The editor will open in your default browser after all the submodules have been installed.

You can also install Cloud9 via NPM
npm install cloud9
or by downloading the source code from Github.
Review
Cloud9′s UI is similar to Eclipse IDE, so Eclipse…
If you are building a Django frontend for a legacy application chances are you will need to integrate your existing user database table(s) with the the Django authentication system (django.contrib.auth). In this tutorial we will look at writing our own authentication backend and plugging it into django.contrib.auth.
Getting Started
Authentication backends are pure python classes. Given a username and password, they are expected to validate them against an authentication source (such as a database) and return a User object. There is no requirement as to where the class is placed, however I always put it in the same directory as the application that handles registrations and logging in.
When a user logs in, Django will check the AUTHENTICATION_BACKENDS (tuple) setting and iterate through all backends until one returns true. The default authentication backend is django.contrib.auth.backends.ModelBackend.
Writing Our Backend
Our backend must have two methods: authenticate and get_user
authenticate takes two arguments – username and password. It is expected to return a User instance or None. The authenticate method should check the given username and password against the user table of the legacy application. If the credentials match, then create a new User instance, save it, and return it. If…
“MongoDB is a scalable, high-performance, open source, schema-free, document-oriented database. Written in C++” – www.mongodb.org (mongodb.org)
There has been alot of publiclity on NOSQL databases over the last few months. CouchDB, Cassandra and Redis are known to be highly scalable and blazingly fast, yet setup and adoption for hobby developers has been relatively low because there is no need for such high scalability and they are relatively difficulty to get setup.
MongoDB strikes a balance between the familiarity and ease of use of MySQL, and the freeness and performance offered by document storage databases. The database has no set schema so you can add, remove and modify the structure of your documents without having to issue an UPDATE statement.
Installation & Setup
Installing MongoDB is very easy. The only setup required is to create the directory that Mongo stores the data in. In Windows the default location is C:\data\db\ and on *nix it is /data/db/. Once the directory is created, download the appropriate Mongo binary from the downloads page (http://www.mongodb.org/display/DOCS/Downloads) and run the bin/mongod file. Mongo should now be up and running.

Now we need to install the PHP extension for MongoDB. If your on Linux or Mac OS…
In this tutorial you will learn how to create and implement an event system in PHP. You will be able to integrate it with your own web application or framework.
What is an event system?
An event system is a way to call prefined functions at a specified time in your application code. It’s main use is to allow developers to add functionality to your code without modifying the original source. Directly editing the source code of an application is proven not to work because every time the software gets updated, the changes made to the source get overwritten. By offering an event system in your application developers will be able to write plugin style code which will get executed at a specified time in the main application code. This makes your platform easier to develop for and offers a low entry level for coders wanting to add functionality themselves.
Overview of the system
event::$events is a static variable (array) which holds all of the registered events and associated Closure objects.
event::register(‘eventName’, function($args){}) accepts two arguments. The first being the name of the event and the second being a Closure object which will be called when the event is fired.…
Cross site request forgery (CSRF) is where a malicious website will attempt to issue actions on another website without the user’s knowledge of it occuring.
Hypothetical Situation: You had just done some online banking and had ticked the ‘Remember me’ option when you logged in. The banking website easily allows you to transfer money to other people. While browsing the malicious site you see a link that seems to take you somewhere harmless but it actually sends you to www.my.bank/transfer?to=3740384342?amount=99999 . Because you ticked ‘remember me’ you are automatically logged in and the bank goes ahead and transfers the funds.
There are some obvious fundamental issues the bank could address such as checking with the user whether they want to send the funds and masking their URLs but the problem of the form still remains. Theres nothing from stopping anyone sending seemingly valid data to the URL the form submits to. This problem is known as Cross Site Request Forgery (CSRF) and it is a potential problem in every single dynamic website. While stealing money is an extreme example, CSRF could also be used to steal cookies from a website or post spammy comments on a blog without the user…
Book Review

PHP in Action is a book aimed at people who are comfortable coding procedural or object orientated PHP scripts. It doesn’t teach you what a variable is or what function to use if you want to connect to a database but it does teach you design patterns, best practice techniques and useful information about PHP5′s object system. If you are looking into writing a PHP framework or want to further understand design patterns and objects in PHP then I highly recommend this book. It’s written by prominent members of the PHP community – Dagfinn Reiersol, Marcus Baker and Chris Shiflett and is 525 pages long.
Overview of the book
Chapters 2,3,4 cover the PHP5 class system. The book offers detailed and useful examples of each of the topics as well as plenty of metaphors to help the reader understand exactly what each feature should do and is capable of doing. I found this contrasted greatly with the almost minimal explanations and examples offered by the official documentation on php.net. The following features are covered:
-
Magic Methods – __get(), __set(), __construct(), __autoload()
-
Exception handling
-
Error handling
…