Install Kohana on Windows

I’m new to Kohana, making this tutorial just want to do something for the community. Please let me know, if you found any mistakes. Ok, let’s cut to the chase.

I suppose you have your server installed, if not I recommand AppServ. It’s better to use the latest version of Kohana from SVN, so you might need TortoiseSVN. I create a folder called Kohana in my webroot, check out the truck folder from SVN, it’s quite easy to do it, right click, select SVN Check…

tortoise SVN

Type http://svn.kohanaphp.com/trunk in URL of repository, click ok, and wait for the download.

tortoise SVN

tortoise SVN

And then you will have three folders: application, modules and system; and three files: index.php, kohana.png, Kohana License.html. To see if Kohana is installed properly, type localhost/Kohana, you will see the welcome page:

Kohana welcome page

Now you may want to do some configuration. Open config.php in /application/config/ folder, the first setting is the site domain, we are using localhost here, so just leave it as ‘/kohana/’. For the second one site protocol, we mostly use ‘http’. That’s all what we do for this moment.

I would like to do some test now. Create a test.php file in /application/controllers/, type in the fellowing codes:

<?php
/**
* Test controller
*/
class Test_Controller extends Template_Controller
{
function __construct()
{

parent::__construct();
//Generate system information, you should try to comment this line to see what will the page be.
$this->profiler = new Profiler;
}

function index()

{
//Set the page title.
$this->template->title = ‘Test Page’;
}
}
?>

We also need to create a template.php in /application/views/, it looks like this:

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>

<head>

<title><?php echo $title ?></title>

<body>

<h2><?php echo $title ?></h2>

</body>
</html>

Back to the blowser, we have visited localhost/kohana, and now we go to localhost/kohana/index.php/test, you should have a page like this:

Kohana setup

There are only two parts in this page, the first one is the title of the page, setting by ‘$this->template->title = “Test Page”;’ and the second part is a table of some system information generated by the profiler library: ‘$this->profiler = new Profiler;’

Ok, that’s all, for further issue, you should keep an eye on my blog and Kohana official website.


Feel free to visit our Forum, subscribe our RRS Feed for news updates, and follow us on Twitter.

Related Posts

Share this Post:
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

7 Responses to “Install Kohana on Windows”

commenter

thx for tutorial, I have error when I tried your example, I used xampp for server php, when I write localhost/kohana on mybrowser it works like yours, can you help me?(I tried your example test.php and template.php and error like this : “Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\Kohana\application\controllers\hello.php on line 14″)

is xampp support to php5(it is used php 5.2.5)?

commenter

As I know, xampp support php5.
You said you try my example test.php and template.php and error is from a “hello.php” controller, I guess you may have some naming problem with files, try to have a look with all the file names, the names of controllers and the names of views, hope this helps.

commenter

I had exactly the same problem. You should change “Test page” to “Test page” in test.php

commenter

Change “Test page” to “Test page” in test.php?
What’s the different?

commenter

The Different is in the “”, it can’t be italic…

commenter

Did I set it to italic? I don’t think so. But I think it’s better to be ‘ ‘ rather than ” “, I’ve corrected my post already.

commenter

It is the same think still…

The problem is the quotes anyhow, nasty html stylizing ;)

profiler = new Profiler;
}

function index() {
//Set the page title.
$this->template->title = ‘Test Page’;
}
}
?>

Leave a Reply:

Name (required):
Mail (will not be published) (required):
Website:
Comment (required):
XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>