SlideShare ist ein Scribd-Unternehmen logo
1 von 27
Have fun with
CodeIgniter Framework
23 April 2016
& Ahmad Arif
About Me
 Pendidikan
 1998-2004 SDN 1 Kertamulya, Karawang
 2004-2007 SMPN 2 Rengasdengklok, Karawang
 2007-2010 SMAN 1 Rengasdengklok, Karawang
 2010-2014 Informatika Universitas Jenderal Achman Yani
 2015-???? Informatika Institut Teknologi Bandung
 Minat
 Programming
 Machine Learning
 Artificial Intelligent
 Game Technology
 Entertainment
 Etc
What is framework?
 Framework = Kerangka kerja
 Menyediakan struktur umum aplikasi sehingga
memudahkan pengembang dalam menyimpan kode
dalam aplikasi
 Menangani tugas umum
– Database
– Business logic
– Form handling
What is CodeIgniter?
 CodeIgniter framework aplikasi web ringan yang ditulis
dalam bahasa pemrograman PHP, dan mengadopsi
pendekatan Model-View-Controller.
Kenapa menggunakan CodeIgniter?
 Feature rich
 Lightweight/small
 Open source
 Well-supported by an active community
 Excellent “by example” documentation
 Easy to configure (nearly zero configuration)
 Supports multiple databases
 Cleaner code
 High Performance
https://github.com/kenjis/php-framework-benchmark
Model-View-Controller
 Model – merepresentasikan data
 View – menyajikan data untuk interaksi dengan user
 Controller – mengontrol model dan data supaya bisa
saling berinteraksi
CodeIgniter Classes
 CI’s built-in classes berisi fungsi dasar yang sering
digunakan oleh aplikasi web
 Beberapa kelas yang sering digunakan:
– Database
– Input
– Loader
– URI
– Validation
Database Class
 Mengolah queri menggunakan the Active Record / ORM
Pattern
 Menyediakan metode “chaining” untuk kemudahan query
 $this->db->where(‘name’,$name);
Input Class
 Menyediakan akses ke input pengguna dan data lainnya:
– Form fields (POST)
– Cookies
– Server variables
 $this->input->post(‘fieldname’);
Loader Class
 Membuat berbagai resource:
– Databases
– Views
– Helpers
– Plugins
 $this->load->view(‘viewname’);
URI Class
 Menyediakan akses ke bagian-bagian tertentu dari String
URI
 Berguna untuk membangung RESTful API
 $this->uri->segment(n);
Other Classes
 Benchmarking
 Calendaring
 Email
 Encryption
 File uploading
 FTP
 HTML Table
 Image Manipulation
 Language
(internationalization)
 Output
 Pagination
 Session
 Trackback
 Unit testing
 XML-RPC
 Zip encoding
Helpers and Plugins
 CodeIgniter dilengkapi dengan berbagai “helper” yaitu
fungsi yang menambahkan kenyamanan terhadap
aplikasi dan memberikan kemudahan reuse code.
 $this->load->helper(‘helper_name’);
 CodeIgniter juga memungkinkan untuk penggunaan
kustom add-on yang disebut “plugins”.
 $this->load->plugin(‘plugin_name’);
Getting Started
 Tools
– Apache HTTP Server
– MySQL Database
– PHP
– Browser
– Code Editor
XAMP, WAMP, MAMP, LAMPP
 Notepad
 Notepad++
 Sublime
 Atom
 PHP Storm
 Etc
Getting Started
 To Do List
– Installation
– Controller
– View
– Model
– RESTful API
Controller
<?php
class BlogController extends CI_Controller {
public function index() {
echo 'Hello World!';
}
public function comments() {
echo 'Look at this!';
}
}
<?php
class BlogController extends CI_Controller {
…
public function page($index) {
echo 'Page: !' . $index;
}
}
View
<html>
<head>
<title>My Blog</title>
</head>
<body>
<h1>Welcome to my Blog!<h1>
</body>
</html>
index.php
$this->load->view(“index”);
Add this code in controller
View
<html>
<head>
<title>My Blog</title>
</head>
<body>
Welcome <strong><?php echo $name ?><strong>
</body>
</html>
index.php
$data = array(
“name” => “Ahmad Arif”
);
$this->load->view(“index”, $data);
Add this code in controller
Model
 Create database and table
 Setting database (config/database.php)
Model
class Blog extends CI_Model {
$tableName = “blog”;
public function insert($title, $content){
$data = array(
“title” => $title,
“content” => $content
);
$this->db->insert($this->tableName, $data);
}
}
Model
class Blog extends CI_Model {
...
public function update($id, $title, $content){
$data = array(
“title” => $title,
“content” => $content
);
$this->db->where(“id”, $id);
$this->db->update($this->tableName, $data);
}
}
Model
class Blog extends CI_Model {
...
public function delete($id){
$this->db->where(“id”, $id);
$this->db->delete($this->tableName);
}
}
Model
class Blog extends CI_Model {
...
public function getAll(){
return $this->db->get($this->tableName)->result();
}
public function getById($id){
$this->db->where(“id”, $id);
return $this->db->get($this->tableName)->row();
}
}
Using Model
class BlogController extends CI_Controller {
...
public function insert(){
$this->load->model(“Blog”);
$title = $this->input->post(“title”);
$content = $this->input->post(“content”);
$this->Blog->insert($title, $content);
}
}
RESTful API
 Tools
– Postman
– Code Editor
 To Do List
– Format JSON/XML
– Routing
– Cache setting
References
 https://codeigniter.com
 https://google.com
 https://github.com/ahmadarif
Tank You

Weitere ähnliche Inhalte

Was ist angesagt?

Codeigniter Introduction
Codeigniter IntroductionCodeigniter Introduction
Codeigniter IntroductionAshfan Ahamed
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterKHALID C
 
Yii2 by Peter Jack Kambey
Yii2 by Peter Jack KambeyYii2 by Peter Jack Kambey
Yii2 by Peter Jack Kambeyk4ndar
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Developmentjoelabrahamsson
 
A site in 15 minutes with yii
A site in 15 minutes with yiiA site in 15 minutes with yii
A site in 15 minutes with yiiAndy Kelk
 
Beautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les HazlewoodBeautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les Hazlewoodjaxconf
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sitesjoelabrahamsson
 
Yii 2.0 overview - 1 of 2
Yii 2.0 overview - 1 of 2Yii 2.0 overview - 1 of 2
Yii 2.0 overview - 1 of 2Cassiano Surek
 
Security enforcement of Java Microservices with Apiman & Keycloak
Security enforcement of Java Microservices with Apiman & KeycloakSecurity enforcement of Java Microservices with Apiman & Keycloak
Security enforcement of Java Microservices with Apiman & KeycloakCharles Moulliard
 
Introduction Yii Framework
Introduction Yii FrameworkIntroduction Yii Framework
Introduction Yii FrameworkTuan Nguyen
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC eldorina
 
Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6Noam Kfir
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 

Was ist angesagt? (20)

Codeigniter Introduction
Codeigniter IntroductionCodeigniter Introduction
Codeigniter Introduction
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
yii1
yii1yii1
yii1
 
Yii2 by Peter Jack Kambey
Yii2 by Peter Jack KambeyYii2 by Peter Jack Kambey
Yii2 by Peter Jack Kambey
 
Progressive EPiServer Development
Progressive EPiServer DevelopmentProgressive EPiServer Development
Progressive EPiServer Development
 
A site in 15 minutes with yii
A site in 15 minutes with yiiA site in 15 minutes with yii
A site in 15 minutes with yii
 
Beautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les HazlewoodBeautiful REST and JSON APIs - Les Hazlewood
Beautiful REST and JSON APIs - Les Hazlewood
 
Automated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS SitesAutomated Testing Of EPiServer CMS Sites
Automated Testing Of EPiServer CMS Sites
 
Yii 2.0 overview - 1 of 2
Yii 2.0 overview - 1 of 2Yii 2.0 overview - 1 of 2
Yii 2.0 overview - 1 of 2
 
Security enforcement of Java Microservices with Apiman & Keycloak
Security enforcement of Java Microservices with Apiman & KeycloakSecurity enforcement of Java Microservices with Apiman & Keycloak
Security enforcement of Java Microservices with Apiman & Keycloak
 
MVC - Introduction
MVC - IntroductionMVC - Introduction
MVC - Introduction
 
What is an API?
What is an API?What is an API?
What is an API?
 
Mule groovy
Mule groovyMule groovy
Mule groovy
 
Introduction Yii Framework
Introduction Yii FrameworkIntroduction Yii Framework
Introduction Yii Framework
 
Api presentation
Api presentationApi presentation
Api presentation
 
Web api
Web apiWeb api
Web api
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
MVC 6 Introduction
MVC 6 IntroductionMVC 6 Introduction
MVC 6 Introduction
 
Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 

Andere mochten auch

Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterPongsakorn U-chupala
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterJamshid Hashimi
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsTuyen Vuong
 
Introduction to codeigniter
Introduction to codeigniterIntroduction to codeigniter
Introduction to codeigniterHarishankaran K
 

Andere mochten auch (11)

Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniter
 
PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Introduction to MySQL
Introduction to MySQLIntroduction to MySQL
Introduction to MySQL
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Introduction to codeigniter
Introduction to codeigniterIntroduction to codeigniter
Introduction to codeigniter
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 

Ähnlich wie Having fun with code igniter

AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )senthil0809
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBo-Yi Wu
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a bossFrancisco Ribeiro
 
Dog food conference creating modular webparts with require js in sharepoint
Dog food conference   creating modular webparts with require js in sharepointDog food conference   creating modular webparts with require js in sharepoint
Dog food conference creating modular webparts with require js in sharepointfahey252
 
In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers PlatformEris Ristemena
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Osconvijayrvr
 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)Tom Johnson
 
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Tom Johnson
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Bastian Feder
 
Online Fitness Gym Documentation
Online Fitness Gym Documentation Online Fitness Gym Documentation
Online Fitness Gym Documentation Abhishek Patel
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introductionvstorm83
 
Vue3: nuove funzionalità, differenze e come migrare
Vue3: nuove funzionalità, differenze e come migrareVue3: nuove funzionalità, differenze e come migrare
Vue3: nuove funzionalità, differenze e come migrareAndrea Campaci
 
Improving code quality using CI
Improving code quality using CIImproving code quality using CI
Improving code quality using CIMartin de Keijzer
 

Ähnlich wie Having fun with code igniter (20)

My Saminar On Php
My Saminar On PhpMy Saminar On Php
My Saminar On Php
 
AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )AIR - Framework ( Cairngorm and Parsley )
AIR - Framework ( Cairngorm and Parsley )
 
Benefit of CodeIgniter php framework
Benefit of CodeIgniter php frameworkBenefit of CodeIgniter php framework
Benefit of CodeIgniter php framework
 
web2py:Web development like a boss
web2py:Web development like a bossweb2py:Web development like a boss
web2py:Web development like a boss
 
Dog food conference creating modular webparts with require js in sharepoint
Dog food conference   creating modular webparts with require js in sharepointDog food conference   creating modular webparts with require js in sharepoint
Dog food conference creating modular webparts with require js in sharepoint
 
Codeignitor
Codeignitor Codeignitor
Codeignitor
 
In Act Developers Platform
In Act Developers PlatformIn Act Developers Platform
In Act Developers Platform
 
Stmik bandung
Stmik bandungStmik bandung
Stmik bandung
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
flask.pptx
flask.pptxflask.pptx
flask.pptx
 
API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)API workshop: Introduction to APIs (TC Camp)
API workshop: Introduction to APIs (TC Camp)
 
Elefrant [ng-Poznan]
Elefrant [ng-Poznan]Elefrant [ng-Poznan]
Elefrant [ng-Poznan]
 
Ide
IdeIde
Ide
 
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
Survival Strategies for API Documentation: Presentation to Southwestern Ontar...
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
Online Fitness Gym Documentation
Online Fitness Gym Documentation Online Fitness Gym Documentation
Online Fitness Gym Documentation
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
Vue3: nuove funzionalità, differenze e come migrare
Vue3: nuove funzionalità, differenze e come migrareVue3: nuove funzionalità, differenze e come migrare
Vue3: nuove funzionalità, differenze e come migrare
 
Improving code quality using CI
Improving code quality using CIImproving code quality using CI
Improving code quality using CI
 

Kürzlich hochgeladen

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Kürzlich hochgeladen (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Having fun with code igniter

  • 1. Have fun with CodeIgniter Framework 23 April 2016 & Ahmad Arif
  • 2. About Me  Pendidikan  1998-2004 SDN 1 Kertamulya, Karawang  2004-2007 SMPN 2 Rengasdengklok, Karawang  2007-2010 SMAN 1 Rengasdengklok, Karawang  2010-2014 Informatika Universitas Jenderal Achman Yani  2015-???? Informatika Institut Teknologi Bandung  Minat  Programming  Machine Learning  Artificial Intelligent  Game Technology  Entertainment  Etc
  • 3. What is framework?  Framework = Kerangka kerja  Menyediakan struktur umum aplikasi sehingga memudahkan pengembang dalam menyimpan kode dalam aplikasi  Menangani tugas umum – Database – Business logic – Form handling
  • 4. What is CodeIgniter?  CodeIgniter framework aplikasi web ringan yang ditulis dalam bahasa pemrograman PHP, dan mengadopsi pendekatan Model-View-Controller.
  • 5. Kenapa menggunakan CodeIgniter?  Feature rich  Lightweight/small  Open source  Well-supported by an active community  Excellent “by example” documentation  Easy to configure (nearly zero configuration)  Supports multiple databases  Cleaner code  High Performance https://github.com/kenjis/php-framework-benchmark
  • 6. Model-View-Controller  Model – merepresentasikan data  View – menyajikan data untuk interaksi dengan user  Controller – mengontrol model dan data supaya bisa saling berinteraksi
  • 7. CodeIgniter Classes  CI’s built-in classes berisi fungsi dasar yang sering digunakan oleh aplikasi web  Beberapa kelas yang sering digunakan: – Database – Input – Loader – URI – Validation
  • 8. Database Class  Mengolah queri menggunakan the Active Record / ORM Pattern  Menyediakan metode “chaining” untuk kemudahan query  $this->db->where(‘name’,$name);
  • 9. Input Class  Menyediakan akses ke input pengguna dan data lainnya: – Form fields (POST) – Cookies – Server variables  $this->input->post(‘fieldname’);
  • 10. Loader Class  Membuat berbagai resource: – Databases – Views – Helpers – Plugins  $this->load->view(‘viewname’);
  • 11. URI Class  Menyediakan akses ke bagian-bagian tertentu dari String URI  Berguna untuk membangung RESTful API  $this->uri->segment(n);
  • 12. Other Classes  Benchmarking  Calendaring  Email  Encryption  File uploading  FTP  HTML Table  Image Manipulation  Language (internationalization)  Output  Pagination  Session  Trackback  Unit testing  XML-RPC  Zip encoding
  • 13. Helpers and Plugins  CodeIgniter dilengkapi dengan berbagai “helper” yaitu fungsi yang menambahkan kenyamanan terhadap aplikasi dan memberikan kemudahan reuse code.  $this->load->helper(‘helper_name’);  CodeIgniter juga memungkinkan untuk penggunaan kustom add-on yang disebut “plugins”.  $this->load->plugin(‘plugin_name’);
  • 14. Getting Started  Tools – Apache HTTP Server – MySQL Database – PHP – Browser – Code Editor XAMP, WAMP, MAMP, LAMPP  Notepad  Notepad++  Sublime  Atom  PHP Storm  Etc
  • 15. Getting Started  To Do List – Installation – Controller – View – Model – RESTful API
  • 16. Controller <?php class BlogController extends CI_Controller { public function index() { echo 'Hello World!'; } public function comments() { echo 'Look at this!'; } } <?php class BlogController extends CI_Controller { … public function page($index) { echo 'Page: !' . $index; } }
  • 17. View <html> <head> <title>My Blog</title> </head> <body> <h1>Welcome to my Blog!<h1> </body> </html> index.php $this->load->view(“index”); Add this code in controller
  • 18. View <html> <head> <title>My Blog</title> </head> <body> Welcome <strong><?php echo $name ?><strong> </body> </html> index.php $data = array( “name” => “Ahmad Arif” ); $this->load->view(“index”, $data); Add this code in controller
  • 19. Model  Create database and table  Setting database (config/database.php)
  • 20. Model class Blog extends CI_Model { $tableName = “blog”; public function insert($title, $content){ $data = array( “title” => $title, “content” => $content ); $this->db->insert($this->tableName, $data); } }
  • 21. Model class Blog extends CI_Model { ... public function update($id, $title, $content){ $data = array( “title” => $title, “content” => $content ); $this->db->where(“id”, $id); $this->db->update($this->tableName, $data); } }
  • 22. Model class Blog extends CI_Model { ... public function delete($id){ $this->db->where(“id”, $id); $this->db->delete($this->tableName); } }
  • 23. Model class Blog extends CI_Model { ... public function getAll(){ return $this->db->get($this->tableName)->result(); } public function getById($id){ $this->db->where(“id”, $id); return $this->db->get($this->tableName)->row(); } }
  • 24. Using Model class BlogController extends CI_Controller { ... public function insert(){ $this->load->model(“Blog”); $title = $this->input->post(“title”); $content = $this->input->post(“content”); $this->Blog->insert($title, $content); } }
  • 25. RESTful API  Tools – Postman – Code Editor  To Do List – Format JSON/XML – Routing – Cache setting

Hinweis der Redaktion

  1. Chain = rantai