Recently, I've been working with the
Kohana PHP Framework and there are a few hurdles I've come across and gotten past - here are a few tips.
Making your own Controller
The default gateway controller with a fresh install of Kohana is 'welcome'. This means that URIs are written a bit like this:
http://localhost/kohana/welcome/index
But it's not ideal to have 'welcome' in the URI all the time. So, if you want to choose a custom name like 'site', you need to make your own controller...
- Copy the welcome controller (welcome.php) in /kohana/applications/controllers/ and paste into the same folder.
- Rename the file to site.php
- Open the site.php file and change the class declaration to 'class Site_Controller extends Template_Controller'
- Now, go to /kohana/system/config/ and copy the file called routes.php to /kohana/application/config/ .
- Open up the file and edit like so: $config['_default'] = 'site';
That should do it. Your site will now build its URIs and route through the 'site' controller by default. You should make urls like so:
<?php html::anchor('site/index', 'Home Page'); ?>
Making your own default template
Simply go to /kohana/system/views/kohana/ and copy the template.php file to /kohana/application/views/kohana/. Edit the file as you wish. But, make sure your controller has this line pointing to it: public $template = 'kohana/template';
Making your CSS and Javascript work (get found)
So you make your XHTML template file and are ready to test everything - you stick your CSS in a .css file and your Javascript into a .js file and your images into an 'images' folder and put them in the root (/kohana/). You go to the page through the URI, e.g. http://localhost/kohana/site/index
Huh? What's this? Your CSS, Javascript and image files were not found!
Turns out you need to change the location of your files and add some PHP to your template.
- make a folder in root (/kohana/) called 'media'.
- make 3 folders called images, css and js inside your media folder and move your images, css and javascript files into their respective folders
- Edit your css and js files to point to the right path for the images, e.g: background-image: url(/kohana/media/simages/bg.png); (make sure the first / is there otherwise it won't work
- Now edit your template file to include this bit of code in the head section (I called my css file and js file css.css and js.js (imaginative huh?)):
<?php echo html::stylesheet(array('media/css/css'), array('screen')) .
html::script(array('media/js/js'), FALSE); ?>
Now this will put the typical XHTML tags into your page to include outside css and js files:
<link rel="stylesheet" type="text/css" href="/kohana/media/css/css.css" media="screen" />
<script type="text/javascript" src="/kohana/media/js/js.js">In 1935, one of the founders of modern genetics, JBS Haldane, studied a group of men with the blood disease haemophilia. He speculated that there would be about 150 new mutations in each of us.
Others have since looked at DNA in chimpanzees to try to produce general estimates for humans.
However, next generation sequencing technology has enabled the scientists to produce a far more direct and reliable estimate.
They looked at thousands of genes in the Y chromosomes of two Chinese men. They knew the men were distantly related, having shared a common ancestor who was born in 1805.
By looking at the number of differences between the two men, and the size of the human genome, they were able to come up with an estimate of between 100 and 200 new mutations per person.
Impressively, it seems that Haldane was right all along.
Unimaginable
One of the scientists, Dr Yali Xue from the Wellcome Trust Sanger Institute in Cambridgeshire, said: "The amount of data we generated would have been unimaginable just a few years ago.
"And finding this tiny number of mutations was more difficult than finding an ant's egg in an emperor's rice store."
New mutations can occasionally lead to severe diseases like cancer. It is hoped that the findings may lead to new ways to reduce mutations and provide insights into human evolution.
Joseph Nadeau, from the Case Western Reserve University in the US, who was not involved in this study said: "New mutations are the source of inherited variation, some of which can lead to disease and dysfunction, and some of which determine the nature and pace of evolutionary change.
"These are exciting times," he added.
"We are finally obtaining good reliable estimates of genetic features that are urgently needed to understand who we are genetically."
http://news.bbc.co.uk/1/hi/sci/tech/8227442.stm