I’m starting on something completely new to me: the Kohana framework, and this is my attempt to document everything I’m learning. When I started this blog, I was already one year into Drupal, and so a lot of the things I struggled with as a noob had more or less evaporated from my mind. For Kohana, I’m a complete noob once again, so hopefully this will be helpful to somebody who’s starting from zero as well.
As of time of writing, the latest stable version of Kohana is v126.96.36.199. There are 2 ways to install Kohana on your system, either download the .zip file from the homepage or get the files via git. If you choose the first option, extract the contents of the .zip file into your local web root. If you choose the second option, navigate to your local web root and run the following:
git clone git://github.com/kohana/kohana.git cd kohana/ git submodule init git submodule update
Note: If you need to use a version of Kohana other than the latest stable version, you can try downloading it from the archives, but the last I tried, the archives were offline. Your best bet is to get it from Kohana’s GitHub repository.
For installation via git, there is an extra step to switch git branches if you need an earlier version.
git clone git://github.com/kohana/kohana.git cd kohana/
To see all the branches, run the following:
git branch -a
For example, if you need v3.0, run:
git checkout 3.0/master
Once you're on the version branch of your choice, run:
git submodule init git submodule update
bootstrap.php file in the
application folder. There are a couple of things to change in this file.
Update your default timezone.
Update the base_url to point to your site installation.
Kohana::init(array( 'base_url' => '/kohana3/', ));
Kohana::modules(array( 'auth' => MODPATH.'auth', // Basic authentication 'cache' => MODPATH.'cache', // Caching with multiple backends 'codebench' => MODPATH.'codebench', // Benchmarking tool 'database' => MODPATH.'database', // Database access 'image' => MODPATH.'image', // Image manipulation 'orm' => MODPATH.'orm', // Object Relationship Mapping 'oauth' => MODPATH.'oauth', // OAuth authentication 'pagination' => MODPATH.'pagination', // Paging of results 'unittest' => MODPATH.'unittest', // Unit testing 'userguide' => MODPATH.'userguide', // User guide and API documentation ));
If you navigate to the site root from your browser, you should see this:
You need to adjust the permissions on the
logs folders. From your terminal, navigate to the
application folder and run the following:
sudo chmod 777 cache/ logs/
Refresh the page and you should now see:
install.php file from the root folder via your favourite method. I just use:
Now, when you refresh the page, you should see a hello, world! message. We now have a fresh Kohana site on our hands to play with.