KEMBAR78
Benefit of CodeIgniter php framework | PPT
Benefit of CodeIgniter  PHP Framework Appleboy (Bo-Yi Wu) 2010.09.19
吳柏毅  (Bo-Yi Wu) – Software Engineer Gemtek  - Wireless Broadband Anywhere  ( 正文科技 ) Android Linux Kernel Driver, Switch Router embedded Linux CodeIgniter  繁體中文手冊翻譯 CodeIgniter  繁體中文網站及討論區 PHP Plurk API (Google Code) About Me
Evolution of Web Development index.php about.php news.php links.php contact.php product.php 剛開始設計網站的時候……… ..
Evolution of Web Development index.php page.php header.php news.php footer.php 當你知道每個網頁都有共同的  header  跟  footer  部份
Evolution of Web Development index.php Controller Model View 當你使用  PHP Framework  設計網站時……
Why use Framework ?
Why use Framework ? A web application framework Dynamic websites Libraries for database access Template frameworks Session management Pagination function Often promote code reuse Many more …….
MVC Architecture WEB SERVER ROUTES Controller View MODEL LAYOUT Database Client BROWSER
MVC View  (views/showProduct.php) <html> <body> <p>Product Count:<?=$count?></p> </body> </html> Controller  (controllers/product.php) function showProduct($id) { $this->load->model(“product”); $count = $this->product->getCount($id); $data[‘count’] = $count; $this->load->view(“showProduct”, $data); } Model  (controllers/product.php) function getCount($id) { $this->db->where(“id”, $id); $this->db->from(“my_product”); $query = $this->db->get(); return $->num_rows(); } View Controller Model
Public Web Framework
Why Choose CodeIgniter Small ( 非常小 ) Fast ( 非常快速,想用什麼就  load  什麼 ) Simple ( 非常簡易 ) Customer 管理者可於幾分鐘內安裝好  CI Framework 對於初學者有豐富線上中文文件 Cleaner Code ( 方便學習如何寫  Framework)
What is CodeIgniter???? An Open Source Web Application Framework Nearly Zero Configuration MVC (Model View Controller) Architecture DB Object Templating Caching Modules Helper Validation
How to install CodeIgniter ?
Requirtment Windows, FreeBSD, Linux...... Apache, lighttpd, Nginx PHP PHP 4.3.2 or Higher.... Database MySQL, MySQLi, MS SQL, Postgres, SQLite...
wget  http://codeigniter.com/ ....... unzip CodeIgniter_1.7.2.zip edit  application/config/config.php application/config/database.php You can see http://localhost/ci/index.php
Application Flow Of CodeIgniter
CodeIgniter URL http://localhost/ news.php ? mode=edit & id=10 http://localhost/index.php/ news / edit / 10
CodeIgniter Directory system user_guide  (English Document) index.php 設定網站  Application  目錄 ,  及  CodeIgniter  核心目錄
CodeIgniter System Directory Application Cache Codeigniter Database .............. Conroller, Model, Views
CodeIgniter Application Directory Config ->  系統相關設定檔 Controllers ->  放置個人  Controller Errors -> CI error message Helpers -> CI Helpers Hooks  Language ->  多國語系 Libraries ->  個人常用函式 Models -> Database  相關語法 Views ->  畫面
Controller class  News  extends Controller {  function __construct() { parent::Controller(); } function  index (){ echo “welcome CodeIgniter”; } } Should be placed under “application/controllers”
Controller class  News  extends Controller {  function __construct() { parent::Controller(); } function  index (){ } function  edit ( $id ){ echo “news id is ” . $id; } } url: http://localhost/ news / edit / 10
Views Should be placed under “application/views/index.php” <html> <title> My First CodeIgniter Project</title> <body> <h1>Welcome to My CodeIgniter</h1> </body> </html>
Views Calling a VIEW from Controller $this->load->view(‘index’); Data Passing to a VIEW from Controller function index() { $data = array( ‘ full_name’ => ‘appleboy’, ‘ email’ => ‘appleboy.tw@gmail.com’ ); $this->load->view(‘index’, $data); }
Views <html> <title> ..::Personal Info::.. </title> <body> Full Name :  <?=$full_name;?> <br /> E-mail  :  <?=$email;?> <br /> </body> </html>
Models Models Should be placed Under “application/models/” class  News_model  extends Model { function Mlb_model() { parent::Model(); }  function  get_news ($id) { $this->db->select(‘news_id, news_name'); $this->db->from('project_news'); $query = $this->db->get(); return $query->result_array(); }  }
Loading a Model inside a Controller $this->load->model(‘news_model’); $data = $this-> news_model -> get_news ();
CodeIgniter Libraries Database ( 支援多種資料庫型態 ) File Uploading ( 檔案上傳 ) Pagination ( 分頁 ) Input and Security (SQL Injection) Session Form Valitation ( 表單驗證 )
How to load  Libraries?
$this->load->library(‘ class name’ );  $this->load->library(‘ validation’ );
CodeIgniter Helpers Url helper site_url() base_url() anchor() mailto() auto_link() Download helper force_download()
How to load  helper?
$this->load->helper(‘helper name’);  $this->load->helper(‘download’);
Auto-loading Resources Core classes found in the &quot; libraries &quot; folder  Helper files found in the &quot; helpers &quot; folder  Plugins found in the &quot; plugins &quot; folder  Config files found in the &quot; config &quot; folder  Language files found in the &quot; language &quot; folder  Models found in the &quot; models &quot; folder
application/config/autoload.php   $autoload [' libraries '] = array(); $autoload [' helper '] = array(); $autoload [' plugin '] = array();
CodeIgniter Online Resource CodeIgniter Wiki ( 超多經典範例及外掛 ) 繁體中文線上文件 ( http://goo.gl/RwaC ) 繁體中文討論區 ( http://goo.gl/CfJi ) Google CodeIgniter ........
Thank You

Benefit of CodeIgniter php framework

  • 1.
    Benefit of CodeIgniter PHP Framework Appleboy (Bo-Yi Wu) 2010.09.19
  • 2.
    吳柏毅 (Bo-YiWu) – Software Engineer Gemtek  - Wireless Broadband Anywhere ( 正文科技 ) Android Linux Kernel Driver, Switch Router embedded Linux CodeIgniter 繁體中文手冊翻譯 CodeIgniter 繁體中文網站及討論區 PHP Plurk API (Google Code) About Me
  • 3.
    Evolution of WebDevelopment index.php about.php news.php links.php contact.php product.php 剛開始設計網站的時候……… ..
  • 4.
    Evolution of WebDevelopment index.php page.php header.php news.php footer.php 當你知道每個網頁都有共同的 header 跟 footer 部份
  • 5.
    Evolution of WebDevelopment index.php Controller Model View 當你使用 PHP Framework 設計網站時……
  • 6.
  • 7.
    Why use Framework? A web application framework Dynamic websites Libraries for database access Template frameworks Session management Pagination function Often promote code reuse Many more …….
  • 8.
    MVC Architecture WEBSERVER ROUTES Controller View MODEL LAYOUT Database Client BROWSER
  • 9.
    MVC View (views/showProduct.php) <html> <body> <p>Product Count:<?=$count?></p> </body> </html> Controller (controllers/product.php) function showProduct($id) { $this->load->model(“product”); $count = $this->product->getCount($id); $data[‘count’] = $count; $this->load->view(“showProduct”, $data); } Model (controllers/product.php) function getCount($id) { $this->db->where(“id”, $id); $this->db->from(“my_product”); $query = $this->db->get(); return $->num_rows(); } View Controller Model
  • 10.
  • 11.
    Why Choose CodeIgniterSmall ( 非常小 ) Fast ( 非常快速,想用什麼就 load 什麼 ) Simple ( 非常簡易 ) Customer 管理者可於幾分鐘內安裝好 CI Framework 對於初學者有豐富線上中文文件 Cleaner Code ( 方便學習如何寫 Framework)
  • 12.
    What is CodeIgniter????An Open Source Web Application Framework Nearly Zero Configuration MVC (Model View Controller) Architecture DB Object Templating Caching Modules Helper Validation
  • 13.
    How to installCodeIgniter ?
  • 14.
    Requirtment Windows, FreeBSD,Linux...... Apache, lighttpd, Nginx PHP PHP 4.3.2 or Higher.... Database MySQL, MySQLi, MS SQL, Postgres, SQLite...
  • 15.
    wget http://codeigniter.com/....... unzip CodeIgniter_1.7.2.zip edit application/config/config.php application/config/database.php You can see http://localhost/ci/index.php
  • 16.
  • 17.
    CodeIgniter URL http://localhost/news.php ? mode=edit & id=10 http://localhost/index.php/ news / edit / 10
  • 18.
    CodeIgniter Directory systemuser_guide (English Document) index.php 設定網站 Application 目錄 , 及 CodeIgniter 核心目錄
  • 19.
    CodeIgniter System DirectoryApplication Cache Codeigniter Database .............. Conroller, Model, Views
  • 20.
    CodeIgniter Application DirectoryConfig -> 系統相關設定檔 Controllers -> 放置個人 Controller Errors -> CI error message Helpers -> CI Helpers Hooks Language -> 多國語系 Libraries -> 個人常用函式 Models -> Database 相關語法 Views -> 畫面
  • 21.
    Controller class News extends Controller { function __construct() { parent::Controller(); } function index (){ echo “welcome CodeIgniter”; } } Should be placed under “application/controllers”
  • 22.
    Controller class News extends Controller { function __construct() { parent::Controller(); } function index (){ } function edit ( $id ){ echo “news id is ” . $id; } } url: http://localhost/ news / edit / 10
  • 23.
    Views Should beplaced under “application/views/index.php” <html> <title> My First CodeIgniter Project</title> <body> <h1>Welcome to My CodeIgniter</h1> </body> </html>
  • 24.
    Views Calling aVIEW from Controller $this->load->view(‘index’); Data Passing to a VIEW from Controller function index() { $data = array( ‘ full_name’ => ‘appleboy’, ‘ email’ => ‘appleboy.tw@gmail.com’ ); $this->load->view(‘index’, $data); }
  • 25.
    Views <html> <title>..::Personal Info::.. </title> <body> Full Name : <?=$full_name;?> <br /> E-mail : <?=$email;?> <br /> </body> </html>
  • 26.
    Models Models Shouldbe placed Under “application/models/” class News_model extends Model { function Mlb_model() { parent::Model(); } function get_news ($id) { $this->db->select(‘news_id, news_name'); $this->db->from('project_news'); $query = $this->db->get(); return $query->result_array(); } }
  • 27.
    Loading a Modelinside a Controller $this->load->model(‘news_model’); $data = $this-> news_model -> get_news ();
  • 28.
    CodeIgniter Libraries Database( 支援多種資料庫型態 ) File Uploading ( 檔案上傳 ) Pagination ( 分頁 ) Input and Security (SQL Injection) Session Form Valitation ( 表單驗證 )
  • 29.
    How to load Libraries?
  • 30.
    $this->load->library(‘ class name’); $this->load->library(‘ validation’ );
  • 31.
    CodeIgniter Helpers Urlhelper site_url() base_url() anchor() mailto() auto_link() Download helper force_download()
  • 32.
    How to load helper?
  • 33.
    $this->load->helper(‘helper name’); $this->load->helper(‘download’);
  • 34.
    Auto-loading Resources Coreclasses found in the &quot; libraries &quot; folder Helper files found in the &quot; helpers &quot; folder Plugins found in the &quot; plugins &quot; folder Config files found in the &quot; config &quot; folder Language files found in the &quot; language &quot; folder Models found in the &quot; models &quot; folder
  • 35.
    application/config/autoload.php $autoload [' libraries '] = array(); $autoload [' helper '] = array(); $autoload [' plugin '] = array();
  • 36.
    CodeIgniter Online ResourceCodeIgniter Wiki ( 超多經典範例及外掛 ) 繁體中文線上文件 ( http://goo.gl/RwaC ) 繁體中文討論區 ( http://goo.gl/CfJi ) Google CodeIgniter ........
  • 37.