isotretinoin in india ephedra yellow swarm fioricet without prescription diazepam cost acomplia tablets purchase nexium amoxycillin price cipro over the counter nexium uk diazepam 500 mg buy ciprofloxacin purchase finasteride oxycontin 15 mg amoxicillin 375 mg effexorxr amoxicillin tablets plavix india order isotretinoin diflucan generic name plavix 2007 generic ciprofloxacin ciprofloxacin medication fioricet drug cheap valtrex effexor xr online diflucan sale meridia tablets nexium 80 mg diazepam no prescription valtrex overnight meridia otc ephedra pharmacy order cipro diflucan uk oxycontin 50 mg ephedra 100mg cheap diazepam amoxicillin pills medicine cipro tamiflu pharmacy ciprofloxacin 1000 mg norvasc 500 cipro 85 cipro prices ciprofloxacin 250mg tablets meridia over the counter ephedra sales diazepam discount norvasc 2007 diazepam 5 mg effexor xr capsule ephedra fat loss cipro tablet plavix 40 tamiflu pig flu meridia no prescription diazepam pharmacy cost of cipro nexium for sale plavix pill generic accutane without prescription oxycontin er 10 mg accutane pills buy effexor xr isotretinoin cost nexium without prescription finasteride in australia finasteride 5 effexor xr cost accutane without prescription effexor xr prices valtrex price name for norvasc valtrex pills ciprofloxacin picture cost of sildenafil diflucan australia sildenafil citrate 100 tamiflu canada accutane prices cost of ciprofloxacin amoxicillin cost norvasc generic effexor xr 75mg meridia discount plavix description amoxycillin 500mg sildenafil for sale diazepam tablets cipro 5 mg cipro price norvasc medicine effexor xr price 30mg oxycontin oxycontin 100mg oxycontin pill pictures ephedra pills buy sildenafil citrate diazepam for sale generic nexium purchase oxycontin generic oxycontin 2007 ciprofloxacin over the counter diflucan usa buy cheap diflucan isotretinoin 10 mg butalbital cod finasteride in uk cheap cipro tamiflu 75mg cipro 10 mg ephedra 1000 diflucan drug medicine sildenafil effexor 150 generic accutane cost diflucan otc order ciprofloxacin acomplia pills amoxicillin 250 mg sildenafil buy nexium purchase sildenafil citrate 25mg butalbital prescription order fioricet oxycontin 30 mg ciprofloxacin 5 mg sildenafil 1 sildenafil australia oxycontin pharmacy purchase ciprofloxacin butalbital 50 mg cheap effexor xr amoxicillin 875 mg ciprofloxacin canada isotretinoin 10mg isotretinoin 40 oxycontin street price canadian plavix finasteride sale diazepam sale oxycontin buy online meridia prices tamiflu sale generic accutane canada purchase norvasc oxycontin street value oxycontin 120 mg oxycontin price online oxycontin plavix 5 mg effexor 37.5 generic butalbital oxycontin for sale plavix cost valtrex 500 mg finasteride from india ciprofloxacin uk nexium price plavix canada plavix 75mg buy accutane online no prescription meridia 20mg finasteride uk finasteride india norvasc 40 cipro 500 ephedra no prescription plavix 100 mg discount valtrex amoxycillin over the counter ephedra supplements diflucan 150 fioricet free shipping cipro cost oxycontin tablets isotretinoin capsules picture of finasteride oxycontin mg ciprofloxacin 500mg tab butalbital online 80 mg oxycontin effexor 150mg sildenafil fast valtrex prices ciprofloxacin for sale generic diflucan oxycontin 100 mg amoxycillin generic ciprofloxacin tablet ephedra yellow jackets norvasc 25 nexium online picture of plavix diflucan price ciprofloxacin hcl 500 valtrex tablets fioricet pills amoxycillin prescription 10mg oxycontin buy amoxicillin buy acomplia sildenafil citrate tablet norvasc pictures plavix from canada sildenafil cost purchase valtrex nexium 30 rebate effexor 225 tamiflu online isotretinoin 40 mg norco online diflucan over the counter generic oxycontin 40 mg norvasc india oxycontin 325 mg plavix rx order sildenafil citrate buy accutane with no prescription buy isotretinoin valtrex 100 mg accutane pharmacy sotret isotretinoin capsules oxycontin generic name acomplia phone order buy cheap accutane online discount sildenafil cipro for sale cheapest plavix cheap tamiflu isotretinoin pills generic meridia meridia uk finasteride usa fioricet tabs buy oxycontin mexico sildenafil 100 ephedra sale medication for norvasc cipro 550 mg cipro alternative plavix uk accutane price fioricet online diflucan medication plavix 75 buy oxycontin without prescription cipro 250mg amoxicillin 500mg acomplia without prescription plavix prescription generic oxycontin photos ciprofloxacin rx710 generic accutane prices generic effexor xr order effexor accutane 10 mg finasteride 5mg accutane pictures ciprofloxacin cost generic vicodin es generic finasteride nexium cost cost of isotretinoin cheap diflucan rimonabant in usa oxycontin without prescription generic oxycontin 40mg amoxycillin 250mg norvasc generic name nexium 4 mg oxycontin with no prescription generic amoxicillin oxycontin without a prescription isotretinoin 2008 order plavix tamiflu tablets generic oxycontin 80mg sildenafil citrate cheap amoxicillin capsule cipro 5312 norvasc online meridia pharmacy oxycontin street drug oxycontin generic pictures valtrex 1 gm rimonabant cheap diazepam 2 mg 160mg oxycontin finasteride medicine name norvasc cipro prescribing the drug cipro norvasc 100 15mg oxycontin norvasc 5mg side generic norvasc side effects generic valtrex fioricet cost accutane price 40 mg fioricet price

Hello World Tutorial for Kohana

Kohana hello world

It seems unnecessary to write a Hello World tuorial for a PHP framework, because when someone comes to framework, he is no longer a beginner, can figure out his own Hello World. But this idea comes up in my brain, and I guess it might be helpful for someone who is the first time to work with MVC or OOP. It’s quite simple, let’s get started.

You should have installed Kohana correctly, now we create a hello.php in /application/controllers/, here is the content of the file:

<?php
/**
* Hello World controller
*/
class Hello_Controller extends Template_Controller
{
function __construct()
{
parent::__construct();
}

function index()
{
$this->template->title = “Hello World”;
$this->template->content = “Hello, welcome to Kohana World !!!”;
}
}
?>

We have a Hello Controller with a index method, so we can call this page in the URL: localhost/kohana/index.php/hello. If you cannot understand this, you may want to see ‘Show me, don’t tell me‘ section in Kohana 101. In the Hello Controller, we set the title and content of our Hello World page, of course you can change the title and content into anything.

Now we have a Controller, we also need a View to reveal the page. Create a template.php in /applicaion/views/, and type in the fellowing codes:

<!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>

<p><?php echo $content ?></p>

</body>
</html>

Very simple HTML codes, echo the title and content set in the Hello Controller to the page, that’s all what it does. You can see how Kohana works, processing in Controller, sending the result to View, and the View exhibit the page.

Usually I’d like to add a profiler to a example page, so that we can see some system information. It’s very easy to do that, just add one line to the Construt function in the Controller:

$this->profiler = new Profiler;

So the Hello Controller file should look like this:

<?php
/**
* Hello World controller
*/
class Hello_Controller extends Template_Controller
{
function __construct()
{
parent::__construct();
$this->profiler = new Profiler;
}

function index()
{
$this->template->title = “Hello World”;
$this->template->content = “Hello, welcome to Kohana World !!!”;
}
}
?>

We can now visit localhost/kohana/index.php/hello, you will have a page the same as the image above.

You already have some basic concepts of Kohana now, I highly recommand you to read Kohana 101, or if you are even not sure how to setup your own Kohana, you can read my post, Install Kohana on Windows. Hope this can help you.


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

8 Responses to “Hello World Tutorial for Kohana”

commenter

can you help me, it isn’t work on my browser I don’t know why,when I write localhost/kohana it’s work but when I tried to your example it isn’t.
i used xampp as server, thx

commenter

Try to check these:
1. The view file should be in folder /applicaion/views/, and should be named as template.php.
2. The hello.php should be in /application/controllers/.
3. Have you done some other configuration, for example, remove index.php from your URL?
3. What do you get, when you visit localhost/kohana/index.php/hello in your browser?

commenter

hello… nice post…

can you give me some tutorial like how to displaying database(mysql) table in browser?

how much file must be created in controllers and views?

pls give me example controller

thank

commenter

@mozink
I will do that later, when I have time.

commenter

Thank you very much. I was wondering how to start with Kohana. I was giving a try to CodeIgniter but i found it a little buggy with PostgreSQL.

commenter

I suggest you to take a look at Kohana101: http://dev.kohanaphp.com/projects/kohana2/wiki/Kohana101

This is for 2.0, there is still no tutorial for 3.0

commenter

wrt a version 3 tutorial, I stumbled upon it at http://v3.kohanaphp.com/
Hope it helps!

commenter

Thanks, Tash Pemhiwa

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>