Ushahidi 101<br /><ul><li>Setting up a development environment
Introduction to MVC and the Kohana (PHP) framework
Working with GIT</li></li></ul><li>Setting up: Prerequisites<br />MySQL<br />PHP 5<br />Apache<br />
Setting up: Code<br />Download and Install GIT (more later)<br />http://git-scm.com/download<br />Clone (‘Checkout’) the c...
Setting up: Database<br />Create a database in mysql called 'ushahidi'.<br />Run USHAHIDI_ROOTsqlunshahidi.sql against DB<...
What is MVC?<br />Model-View-Controller<br />Separates:<br />M: Data model<br />V: Presentation (UI)<br />C: Business logi...
What is MVC?<br />A Model represents a data structure, usually this is a table in a database.<br />A View contains present...
Why use an MVC framework?<br />Avoid “reinventing the wheel”<br />Use proven, tested code<br />Automation (ORM, generators...
Flow: Traditional vs. MVC<br />Query<br />Controller<br />Model<br />Processing<br />Output<br />Output<br />Query<br />Ou...
Kohana<br />Kohana (http://kohanaframework.org/) is a PHP5 framework that uses the Model View Controller architectural pat...
class Country_Modelextends ORM<br />{<br />protected $belongs_to= array('location');<br />protected $has_many= array('city...
<div id="content"><br /><div class="content-bg"><br /><!-- start search block --><br /><div class="big-block"><br /><h1>Se...
Example Controller: Error <br />class Error_Controllerextends Controller<br />{<br />/**<br /> * Render Custom 404 Error P...
Working with GIT<br />GIT is a version control system much like SVN<br />The concepts are more or less the same - revision...
Basic commands<br />
Learning Links<br />GitHub Guide - http://github.com/guides<br />Git Home - http://git.or.cz/<br />http://github.com/guide...
Upcoming SlideShare
Loading in...5
×

Intro to Ushahidi for Developers

5,513

Published on

Intro to Ushahidi for developers. Prepared by Wilfred Mworia and Linda Kamau - Ushahidi Devs.

Published in: Technology

Intro to Ushahidi for Developers

  1. 1. Ushahidi 101<br /><ul><li>Setting up a development environment
  2. 2. Introduction to MVC and the Kohana (PHP) framework
  3. 3. Working with GIT</li></li></ul><li>Setting up: Prerequisites<br />MySQL<br />PHP 5<br />Apache<br />
  4. 4. Setting up: Code<br />Download and Install GIT (more later)<br />http://git-scm.com/download<br />Clone (‘Checkout’) the code<br />cd [WORKING DIRECTORY]<br />git clone git://github.com/ushahidi/Ushahidi_Web.git<br />Fire up editor (e.g. Zend) and set up a new project from existing code<br />
  5. 5.
  6. 6. Setting up: Database<br />Create a database in mysql called 'ushahidi'.<br />Run USHAHIDI_ROOTsqlunshahidi.sql against DB<br />Go to USHAHIDI_ROOTapplicationconfigdatabase.php and edit the user, database and host configurations.<br />
  7. 7. What is MVC?<br />Model-View-Controller<br />Separates:<br />M: Data model<br />V: Presentation (UI)<br />C: Business logic<br />Can change any of these three without affecting the others (in theory)<br />
  8. 8. What is MVC?<br />A Model represents a data structure, usually this is a table in a database.<br />A View contains presentation code such as HTML, CSS and JavaScript.<br />A Controller contains the page logic to tie everything together and generate the page the user sees.<br />
  9. 9. Why use an MVC framework?<br />Avoid “reinventing the wheel”<br />Use proven, tested code<br />Automation (ORM, generators)<br />Maintainability<br />“Plugin” functionality<br />…<br />
  10. 10. Flow: Traditional vs. MVC<br />Query<br />Controller<br />Model<br />Processing<br />Output<br />Output<br />Query<br />Output<br />Processing<br />View<br />Final Output<br />
  11. 11. Kohana<br />Kohana (http://kohanaframework.org/) is a PHP5 framework that uses the Model View Controller architectural pattern. It aims to be secure, lightweight, and easy to use.<br />Documentation: http://docs.kohanaphp.com/ <br />http://learn.kohanaphp.com/ <br />
  12. 12.
  13. 13.
  14. 14.
  15. 15. class Country_Modelextends ORM<br />{<br />protected $belongs_to= array('location');<br />protected $has_many= array('city');<br />// Database table name<br />protected $table_name= 'country';<br />}<br />Example Model: Country<br />
  16. 16. <div id="content"><br /><div class="content-bg"><br /><!-- start search block --><br /><div class="big-block"><br /><h1>Search Results</h1><br /><div class="search_block"><br /><?phpecho $search_info; ?><br /><?phpecho $search_results; ?><br /></div><br /></div><br /><!-- end search block --><br /></div><br /></div><br /></div><br /></div><br /></div><br />Example View: Search Results<br />
  17. 17. Example Controller: Error <br />class Error_Controllerextends Controller<br />{<br />/**<br /> * Render Custom 404 Error Page<br /> */<br />public function error_404()<br />{<br />Header("HTTP/1.0 404 Not Found");<br />$this->layout = new View('error');<br />$this->layout->title = Kohana::lang('ui_admin.page_not_found');<br />$this->layout->content = Kohana::lang('ui_admin.page_not_found_message');<br />$this->layout->render(true);<br />}<br />}<br />
  18. 18. Working with GIT<br />GIT is a version control system much like SVN<br />The concepts are more or less the same - revisions, commits… <br />Ushahidi hosts source code repositories with GitHub - <br />http://github.com/ushahidi<br />http://github.com/ushahidi/Ushahidi_Web<br />
  19. 19. Basic commands<br />
  20. 20. Learning Links<br />GitHub Guide - http://github.com/guides<br />Git Home - http://git.or.cz/<br />http://github.com/guides/git-cheat-sheet<br />Git - SVN Crash Course - http://git.or.cz/course/svn.html<br />O'Reilly Webcast: Git in One Hour - http://www.youtube.com/watch?v=OFkgSjRnay4<br />
  21. 21. More<br />Developer guide: http://wiki.ushahidi.com/doku.php?id=developer<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×