CodeIgniter - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

CodeIgniter

Description:

CodeIgniter CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 33
Provided by: sula3
Category:

less

Transcript and Presenter's Notes

Title: CodeIgniter


1
CodeIgniter
  • CodeIgniter is a powerful PHP framework with a
    very small footprint, built for PHP coders who
    need a simple and elegant toolkit to create
    full-featured web applications
  • Shofiq Sulaiman shofiqsula_at_yahoo.com

2
  • HTML
  • ltform method"POST" action"index.php"gt
  • lttablegt .
  • CSS
  • .input
  • width140px.
  • Javascript
  • ltscriptgt
  • function ()
  • PHP
  • lt?php
  • link mysql_connect('localhost', 'root',
    'sula')
  • mysql_select_db('mitm')
  • Query Database
  • INSERT INTO
  • buku_tamu (BukuTamuNama,BukuTamuEmail,BukuTamuIs
    i)

3
(No Transcript)
4
(No Transcript)
5
  • Perawatan
  • Pembaharuan
  • Tetapi, adakah
  • keunggulannya ?

6
  • Adalah sekumpulan fungsi, class, dan
    aturan-aturan.
  • Berbeda dengan library yang sifatnya untuk tujuan
    tertentu saja, framework bersifat menyeluruh
    mengatur bagaimana kita membangun aplikasi.
  • Lebih Cepat, Lebih Baik.
  • Developer akan lebih fokus pada pokok
    permasalahan (masalah koneksi database, form
    validation, GUI, security, dsb telah disediakan
    oleh framework atau library).
  • Teknologi tinggi berbiaya rendah
  • Alih-alih membangun semuanya sendirian, lebih
    baik menggunakan resource yang sudah ada dan
    teruji (Ancaman Sang Naga, Ming Zeng, hal 55)

7
(No Transcript)
8
(No Transcript)
9
  • Model
  • Connects business objects and database tables to
    create a persistable domain model where logic and
    data are presented in one wrapping.
  • View
  • Helper classes to display html elements in your
    views.
  • Controller
  • Is made up of one or more actions that performs
    its purpose and then either renders a template or
    redirects to another action. An action is defined
    as a public method in the controller, which will
    automatically be made accessible to the
    web-server through a mod_rewrite mapping.

10
  • The Model represents your data structures.
    Typically your model classes will contain
    functions that help you retrieve, insert, and
    update information in your database.
  • The View is the information that is being
    presented to a user. A View will normally be a
    web page, but in CodeIgniter, a view can also be
    a page fragment like a header or footer. It can
    also be an RSS page, or any other type of "page".
  • The Controller serves as an intermediary between
    the Model, the View, and any other resources
    needed to process the HTTP request and generate a
    web page.

11
  • Keuntungan
  • Struktur yang konsisten. Sangat berguna bila
    developer banyak dan turnover tinggi.
  • Struktur merupakan best practices. Semua sudah
    ditempatkan di tempat yang paling sesuai.
  • Dapat belajar tentang desain aplikasi yang baik.
  • Hanya library dan helper yang dibutuhkan yang
    diload.
  • Dokumentasi yang lengkap
  • Kerugian
  • Butuh investasi waktu belajar dan adaptasi

12
  • Web Server Database
  • Apache, PHP, MySQL, WAMP, LAMP, AppServ, dsb
  • Editor Code
  • PSPad, Dreamweaver, Notepad, dsb
  • Browser
  • IE, Firefox Mozila, Chrome, Opera, Safari, dsb
  • CodeIgniter
  • CodeIgniter_1.7.0.zip
  • Jika belum ada sebagian atau seluruhnya belum
  • ada, anda dapat ambil di \\sulaiman\windows\
  • Ekstrak CodeIgniter_1.7.0.zip dan langsung jalan ?

13
(No Transcript)
14
(No Transcript)
15
  1. The index.php serves as the front controller,
    initializing the base resources needed to run
    CodeIgniter.
  2. The Router examines the HTTP request to determine
    what should be done with it.
  3. If a cache file exists, it is sent directly to
    the browser, bypassing the normal system
    execution.
  4. Security. Before the application controller is
    loaded, the HTTP request and any user submitted
    data is filtered for security.
  5. The Controller loads the model, core libraries,
    plugins, helpers, and any other resources needed
    to process the specific request.
  6. The finalized View is rendered then sent to the
    web browser to be seen. If caching is enabled,
    the view is cached first so that on subsequent
    requests it can be served.

16
  • A Controller is simply a class file that is named
    in a way that can be associated with a URI.
  • The second segment of the URI determines which
    function in the controller gets called.
  • If your URI contains more then two segments they
    will be passed to your function as parameters.
  • A view is simply a web page, or a page fragment,
    like a header, footer, sidebar, etc.
  • To load a particular view file you will use the
    following function
  • this-gtload-gtview('name, data)
  • Models are PHP classes that are designed to work
    with information in your database.
  • To load a model you will use the following
    function
  • this-gtload-gtmodel('Model_name')

17
  • helper file is simply a collection of functions
    in a particular category, performs one specific
    task, with no dependence on other functions
  • Loading a helper file is quite simple using the
    following function
  • this-gtload-gthelper('name')
  • Auto-loading Helpers in application/config/autoloa
    d.php file
  • Once you've loaded the Helper File containing the
    function you intend to use, you'll call it the
    way you would a standard PHP function.
  • Plugins work almost identically to Helpers
  • plugin usually provides a single function,
    whereas a Helper is usually a collection of
    functions
  • Loading a plugin file is quite simple using the
    following function
  • this-gtload-gtplugin('name')
  • Auto-loading Plugins in application/config/autoloa
    d.php file
  • Menggunakan fungsi dalam library
  • this-gtsomeclass-gtsome_function()  // Object
    instances will always be lower case

18
  • lt?php if ( ! defined('BASEPATH')) exit('No direct
    script access allowed') class Someclass
        function some_function()     ?gt
  • XSS Filtering
  • config'global_xss_filtering' TRUE
  • Active Record
  • query this-gtdb-gtget('mytable')// Produces
    SELECT FROM mytable
  • Parser
  • lth5gtjudullt/h5gt
  • this-gtparser-gtparse(judul', CodeIgniter)

19
  • Fungsi
  • function SetTanggal(tanggal)
    blnarray('Januari','Februari','Maret','April','M
    ei','Juni','Juli ,'Agustus,
    'September','Oktober','November','Desember')
  • tlen sizeof(bln)
  • tglexplode('-',tanggal)
  • for (t0tlttlent)
  • if (tgl1t1) tgl1blnt
  • tanggaltgl2.' '.tgl1.' '.tgl0
  • return tanggal
  • Pemakaian
  • tanggal SetTanggal(2009-05-03)

20
  • Class
  • class Waktu
  • function Waktu()
  • function SetWaktu(waktu)
  • wakt explode(" ",waktu)
  • tanggal wakt0
  • return tanggal.' '.wakt1
  • Pemakaian
  • waktuObj new Waktu()
  • waktu waktuObj-gtSetWaktu(2009-05-03
    121320)

21
CREATE DATABASE mitm USE mitm CREATE
TABLE buku_tamu ( BukuTamuId int(10) NOT
NULL auto_increment, BukuTamuNama char(30)
default NULL, BukuTamuEmail char(50) default
NULL, BukuTamuIsi char(255) default NULL,
BukuTamuWaktu datetime default NULL, PRIMARY
KEY (BukuTamuId) ) ENGINEInnoDB
AUTO_INCREMENT2 DEFAULT CHARSETlatin1 insert
into buku_tamu(BukuTamuId,BukuTamuNama,Buku
TamuEmail,BukuTamuIsi,BukuTamuWaktu) values
(1,'Sulaiman','shofiqsula_at_yahoo.com','Yang
pertama nie','2009-05-23 132152')
22
(No Transcript)
23
(No Transcript)
24
(No Transcript)
25
(No Transcript)
26
(No Transcript)
27
  • Telah diberikan contoh untuk menampilkan data
    buku tamu dari
  • database di atas
  • Dengan code di atas kita dapat melihat daftar
    buku tamu sekaligus
  • menambahkannnya
  • Silahkan anda lengkapi untuk aksi edit dan delete
    data
  • Setelah itu tambahkan paging

28
(No Transcript)
29
(No Transcript)
30
(No Transcript)
31
(No Transcript)
32
  • Banyak hal dalam CodeIgniter yang belum
    tersampaikan
  • Mohon maaf dan terima kasih
Write a Comment
User Comments (0)
About PowerShow.com