1 / 32

CodeIgniter

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@yahoo.com]. HTML < form method=" POST " action=" index.php "> < table > ….

justis
Download Presentation

CodeIgniter

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 ShofiqSulaiman [shofiqsula@yahoo.com]

  2. HTML <form method="POST" action="index.php"> <table> …. • CSS .input{ width:140px;…. • Javascript <script> function () {… • PHP <?php $link = mysql_connect('localhost', 'root', 'sula'); mysql_select_db('mitm');… • Query Database INSERT INTO buku_tamu (BukuTamuNama,BukuTamuEmail,BukuTamuIsi) …

  3. Perawatan • Pembaharuan • Tetapi, adakah keunggulannya ?

  4. Adalahsekumpulanfungsi, class, danaturan-aturan. • Berbedadengan library yang sifatnyauntuktujuantertentusaja, framework bersifatmenyeluruhmengaturbagaimanakitamembangunaplikasi. • LebihCepat, LebihBaik. Developer akanlebihfokuspadapokokpermasalahan (masalahkoneksi database, form validation, GUI, security, dsbtelahdisediakanoleh framework atau library). • Teknologitinggiberbiayarendah Alih-alihmembangunsemuanyasendirian, lebihbaikmenggunakan resource yang sudahadadanteruji (Ancaman Sang Naga, Ming Zeng, hal 55)

  5. 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.

  6. 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.

  7. Keuntungan • Struktur yang konsisten. Sangatbergunabila developer banyakdan turnover tinggi. • Strukturmerupakan best practices. Semuasudahditempatkanditempat yang paling sesuai. • Dapatbelajartentangdesainaplikasi yang baik. • Hanya library dan helper yang dibutuhkan yang diload. • Dokumentasi yang lengkap Kerugian • Butuhinvestasiwaktubelajardanadaptasi

  8. 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 Jikabelumadasebagianatauseluruhnyabelum ada, andadapatambildi\\sulaiman\windows\ • Ekstrak CodeIgniter_1.7.0.zip danlangsungjalan

  9. The index.php serves as the front controller, initializing the base resources needed to run CodeIgniter. The Router examines the HTTP request to determine what should be done with it. If a cache file exists, it is sent directly to the browser, bypassing the normal system execution. Security. Before the application controller is loaded, the HTTP request and any user submitted data is filtered for security. The Controller loads the model, core libraries, plugins, helpers, and any other resources needed to process the specific request. 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.

  10. 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->load->view('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->load->model('Model_name');

  11. 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->load->helper('name'); • Auto-loading Helpers in application/config/autoload.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->load->plugin('name'); • Auto-loading Plugins in application/config/autoload.php file • Menggunakan fungsi dalam library : • $this->someclass->some_function();  // Object instances will always be lower case

  12. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Someclass {    function some_function() {    }}?> • XSS Filtering • $config['global_xss_filtering'] = TRUE; • Active Record • $query = $this->db->get('mytable');// Produces: SELECT * FROM mytable • Parser • <h5>{judul}</h5> • $this->parser->parse(‘judul', ‘CodeIgniter’);

  13. Fungsi • function SetTanggal($tanggal) { $bln=array('Januari','Februari','Maret','April','Mei','Juni','Juli‘ ,'Agustus‘, 'September','Oktober','November','Desember'); • $tlen = sizeof($bln); • $tgl=explode('-',$tanggal); • for ($t=0;$t<$tlen;$t++) { • if ($tgl[1]==$t+1) $tgl[1]=$bln[$t]; • } • $tanggal=$tgl[2].' '.$tgl[1].' '.$tgl[0]; • return $tanggal; • } • Pemakaian • $tanggal = SetTanggal(‘2009-05-03’);

  14. Class • class Waktu { • function Waktu() { • … • } • function SetWaktu($waktu) { • $wakt = explode(" ",$waktu); • $tanggal = $wakt[0]; • … • return $tanggal.' '.$wakt[1]; • } • } • Pemakaian • $waktuObj = new Waktu(); • $waktu = $waktuObj->SetWaktu(‘2009-05-03 12:13:20’);

  15. 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`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; insert into `buku_tamu`(`BukuTamuId`,`BukuTamuNama`,`BukuTamuEmail`,`BukuTamuIsi`,`BukuTamuWaktu`) values (1,'Sulaiman','shofiqsula@yahoo.com','Yang pertama nie','2009-05-23 13:21:52');

  16. Telahdiberikancontohuntukmenampilkan data bukutamudari • database diatas • Dengan code diataskitadapatmelihatdaftarbukutamusekaligus • menambahkannnya • Silahkanandalengkapiuntukaksi edit dan delete data • Setelahitutambahkan paging

  17. BanyakhaldalamCodeIgniter yang belumtersampaikan • Mohonmaafdanterimakasih

More Related