Ramblings on technology with a dash of social commentary
RSS icon Email icon Home icon
  • Kohana 3.x in 10 Minutes

    Posted on June 11th, 2011 phpguru No comments

    Prerequisites:

    This guide assumes you have already completed:

    So you have a LAMP/MAMP/XAMPP stack? Great!

    Now we’re ready to create our first Kohana project.

    1. Download the source from www.KohanaFramework.org
    2. Extract the zip file and move the directory it to your  web directory
      1. On Mac OS X: ~/Sites/* (subsequent references will use Mac notation)
      2. On Windows (wamp): C:/wamp/www/*
      3. On Linux (varies): /var/www/*
    3. Rename the directory to kohanasite.dev
      1. Remember the full path to this now
      2. something like /Users/yourname/Sites/kohanasite.dev
    4. Create an htdocs directory inside this directory
      1. Your hdtocs will be at the same level as Kohana folders application, modules and system.
      2. Remember the full path to this now
      3. something like /Users/yourname/Sites/kohanasite.dev/htdocs
    5. Drag index.php into the htdocs directory
    6. Edit 3 lines of index.php
      1. where it says $application = ‘application’; change it to $application = ‘../application’;
      2. where it says $modules = ‘modules’; change it to $modules = ‘../modules’;
      3. where it says $system = ‘system’; change it to $system = ‘../system’;
      4. save and close
    7. chmod or chown application/cache and application/logs to be writable by Apache
      1. open terminal, and cd to your application directory
        cd /Users/your-name/Sites/kohanasite.dev/htdocs
      2. chmod the two directories
        chmod 0777 cache && chmod 0777 cache
      3. or chown it to apache, wheel, www-data or whoever owns httpd process (ps aux | grep httpd)
    8. Create a VirtualHost entry in your Apache config.
      1. Depending on your install, this might be in httpd.conf or…
      2. on my Mac it’s at /private/etc/apache2/extra/httpd-vhosts.conf
      3. E.g.
        sudo vi /private/etc/apache2/extra/httpd-vhosts.conf
        NameVirtualHost *:80
        <VirtualHost *:80>
        ServerName kohanasite.dev
        DocumentRoot "/Users/your-username-here/Sites/kohanasite.dev/htdocs"
        </VirtualHost>
      4. save and quit (type :wq and hit enter)
    9. Edit your hosts file to point to this site locally
      1. E.g.
        sudo vi /etc/hosts
        127.0.0.1   kohanasite.dev
      2. save and quit (:wq)
    10. Restart Apache
      1. sudo apachectl restart
    11. Move example.htaccess to htdocs and rename it to .htaccess
      1. Note, because it’s a “dot file” it will disappear on a Mac, so use terminal:
        mv ../example.htaccess .htaccess
    12. Now test your site at http://kohanasite.dev
      1. It should say Hello World!

    Congratulations! You now have Kohana 3.1 running locally.

    Finishing up…

    Let’s enable some of the modules that come with Kohana 3.x

    1. Open up application/bootstrap.php
    2. Scroll down to the modules section
    3. Enable the following modules by removing the double slash in front of the module name:
      1. auth
      2. cache
      3. codebench
      4. database
      5. orm
      6. userguide
    4. Save the bootstrap file and refresh your browser to make sure you still get hello world

     

    Next up… How to build a simple CMS using Kohana.

  • New Kohana 3 Resources

    Posted on November 29th, 2010 phpguru No comments

    Kohana 3 is getting new fixes and upgrades every day. Here’s the latest batch of helpful new Kohana 3 resources on various topics.

    From Mixu.net…

    Kohana 3 Form Validation – validating form input (here’s another post on user input in Kohana 3)

    Kohana 3 i18n – localization/internationalization

    From Kerkness.ca…

    Kohana 3 ORM – Object Relational Mapping

    From DealTaker.com – now a 9 part Kohana 3 tutorial series

    Kohana 3 Routing – Choosing the right action based on the request

    From o1iver.net…

    Kohana 3 Introduction – 3 part series

    From elsewhere…

    Kohana 3 resized image urls

    Migrating to Kohana 3 from Dupal in 2 weeks

    Custom 404 page in Kohana 3

    Awesome explanation with diagram of (H)MVC

    Seems more are coming out every day. Kohana 3 rocks.

  • Kohana 3 PHP Development Resources

    Posted on December 31st, 2009 phpguru No comments

    Here is the most current Kohana 3 Documentation.

    Here is the Kohana 3 API.

    Here is the Kohana 3 Unofficial Wiki.

    Here is a link to all posts tagged with KO3 in the KohanaPHP Forums.

    Here is a search result for KO3 Models. Models represent the ‘M’ in the MVC software design pattern. Chances are your Models will use a Database backend. Here’s the KO3 Database tutorial.

    Here’s a great tutorial on using Views with Kohana 3. Views represent the ‘V’ in the MVC software design pattern. Update: Now there’s 8 Great Kohana 3 Tutorials at DealTaker.

    Here is a search result for KO3 Controllers. Controllers represent the ‘C’ in the MVC software design pattern. In order to decide what Controller (and Action) to run, you need to use KO3 Routing.

    Once you get the hang of things, you’ll find this KO3 Cheat Sheet comes in very handy, as does this Git Cheat Sheet!