Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Intro to Ushahidi for Developers


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 /><br />Clone (‘Checkout’) the code<br />cd [WORKING DIRECTORY]<br />git clone 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 ( is a PHP5 framework that uses the Model View Controller architectural pattern. It aims to be secure, lightweight, and easy to use.<br />Documentation: <br /> <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 /><br /><br />
  19. 19. Basic commands<br />
  20. 20. Learning Links<br />GitHub Guide -<br />Git Home -<br /><br />Git - SVN Crash Course -<br />O'Reilly Webcast: Git in One Hour -<br />
  21. 21. More<br />Developer guide:<br />