Saturday, January 11, 2014

When it comes to removing index.php from url Kohana documentation is not very helpful (or at least does not tell anything useful.)

There are 2 steps:

1 .You have to add this code to your bootstrap.php

Kohana::init(array(
    'base_url'   => '/myapp/',
    'index_file' => FALSE,
));

2. Change your .htaccess file into this:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /kohana/

# Allow these directories and files to be displayed directly:
# - index.php (DO NOT FORGET THIS!)
# - robots.txt
# - favicon.ico
# - Any file inside of the media/ directory
RewriteRule ^(index\.php|robots\.txt|favicon\.ico|media|uploads) - [PT,L]

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php?/$0 [PT,L,QSA]

See this thread for details.

Actually you have to put your media files (like js, img or css) in main directory, the same where your application and system lives.

Do not forget to check if mod_rewrite is enabled.

Friday, December 13, 2013

Programming Environment for PHP and Kohana - the Easy and Completely Unproffessional Way

As a complete PHP idiot and not proffesional programmer I was looking for the best programming environment for casual programming. For some reason I did not wanted to polute my computer with apache and PHP, so naturally I looked into virutal machines and LAMP.

After 3 afternoons of messing around with VirtualBox, Ubuntu, PHP and Apache installation I finally successfully installed everything and made sure PHP an Apache is running. I even installed Wordpress, but then, suddenly it turned out that I am not able to install any plugins.

I am sure this was something along the lines of users and access rights, but I just gave up as I am not an expert in Unixes and did not have time to become one.

Then, when browsing on Wordpress.org I found (almost) perfect solution form PHP develompent, which does not reqiure PHP or Apache installation. It is called Instant Wordpress.

When you need to run Apache/PHP (and WordPress for that matter) you just start Instant Wordpress and when you close it, Apache/PHP shuts down and your projects stay untouched, ready for your next session programming session.

I know, I abuse Instant Wordpress as it is intended to develop for Wrodpress (duh!), but I cannot see any reason not to use it for Kohana!