Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to CodeIgniter

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Introduction to CodeIgniter

for C4Labs

Avatar for johnroyer

johnroyer

June 14, 2012
Tweet

More Decks by johnroyer

Other Decks in Programming

Transcript

  1. 重複的程式碼 $user = trim( mysql_escape_string($_POST[‘user’] ) mysql_escape_string($_POST[‘user’] ) ); $pwd

    = trim( mysql_escape_string($_POST[‘pwd’] ) mysql_escape_string($_POST[‘pwd’] ) ); 5
  2. 架構 $ tree • • ├── html ├── lib ├──

    upload ├── config.php.sample ├── ├── global.php └── index.php 7
  3. 22

  4. 23

  5. 24

  6. CodeIgniter 簡介 Installation Structure Structure Configuration URLs Controller / Model

    / View Controller / Model / View Built-in Functions Sparks 32
  7. 34

  8. Structure ─── application ├── config ├── config ├── controllers ├──

    models ├── views ├── ........ ├── ........ ├── system └── index.php 37
  9. Structure ─── application 網站程式所在位置 ├── config ├── config ├── controllers

    ├── models ├── views ├── ........ ├── ........ ├── system └── index.php 38
  10. Structure ─── application ├── config ├── config ├── controllers ├──

    models ├── views ├── ........ ├── ........ ├── system CodeIgniter 核心 └── index.php 39
  11. URLs class Post extends CI_Controller { class Post extends CI_Controller

    { public function show($id){ // Get post information } } } 46
  12. Your Own Controller controller/hello.php class Hello extends CI_Controller { class

    Hello extends CI_Controller { public function greeting($id){ echo “Hello $id”; } } } 50
  13. Your Own Controller controller/hello.php class Hello extends CI_Controller { class

    Hello extends CI_Controller { public function greeting($id){ echo “Hello $id”; } } } Print ‘Hello C4Labs’ : index.php/hello/greeting/C4Labs 51
  14. Your Own Controller Deny method from URL access class Hello

    extends CI_Controller { public function _greeting($id){ echo “Hello $id”; echo “Hello $id”; } } 52 Underline
  15. Model Process data in database class User extends CI_Model{ function

    getUser($uid) { ... } function deleteUser($uid) { ... } function deleteUser($uid) { ... } } 59
  16. Using Sparks $ php tools/spark search redis menu - The

    Menu library is used to .... menu - The Menu library is used to .... redis - A CodeIgniter library to .... $ php tools/spark install redis Retrieving spark detail from getsparks.org ........ Spark installed to ./sparks/redis/0.3.0 - You're on fire! 67