Ian J Robotham Software Development Lead Medi-CAL Unit, University of Aberdeen

excitingwonderlakeInternet and Web Development

Dec 13, 2013 (3 years and 7 months ago)

95 views

Ian J Robotham

Software Development Lead

Medi
-
CAL Unit, University of Aberdeen

Who?


Ellis Labs Inc.


Based in Bend, Oregon

What?


Open source Web Application Framework


Lightweight


Available for 5 years

Why?


Rapid Application Development


Noted for Speed


Handles much of the mundane


query
processing, pagination, validation etc.

MVC

Controller

Model

View

Getting Started


http://codeigniter.com/downloads
/


Download, extract & rename = “working” app


Configure & Code


Security


URL


Anti
register_globals


XSS Filtering


CSRF


Automatic GET/POST/COOKIE cleaning


Database escaping

Active Record


Modified version of design pattern


Database independence*


Allows chaining (PHP5+)


$query = $this
-
>
db
-
>from(‘users’)


-
>where(‘
dept
’, ‘DIT’)



-
>
order_by
(‘
lastname

asc
’);

foreach

($query
-
>result() as $row
) {


echo $row
-
>
firstname
.’ ‘.$row
-
>
lastname
;

}

Form Validation


In controller


Some exists but can write own tests


$
this
-
>load
-
>library('
form_validation
');

$
this
-
>
form_validation
-
>
set_rules
('username', 'Username', 'required');

$
this
-
>
form_validation
-
>
set_rules
('password', 'Password', 'required');

$
this
-
>
form_validation
-
>
set_rules
('
passconf
', 'Password Confirmation',
'required');

$
this
-
>
form_validation
-
>
set_rules
('email', 'Email',
'
required|valid_email
');


if
($this
-
>
form_validation
-
>run() == FALSE
) {


$
this
-
>load
-
>view('
myform
');

} else {


$
this
-
>load
-
>view('
formsuccess
');

}

Libraries


Classes to add functionality


Write own (or use other external)


Extend native CI libraries


Replace native CI libraries


E.g. use to add TCPDF for PDF generation or
ExcelWriter

etc.


Can call elements of CI core

Helpers


Collection of functions


Not OO


Independent


Can use in views, controller


Can call CI core if needed

Inheritance


Useful in Controllers & Models


Create
UOA_Model

which each model
extends


Handle simple CRUD calls


Create
UOA_Controller

which each
controller extends


Handle common functions e.g. security checks etc
.

Sparks


Fairly new


http://getsparks.org
/


Repository of CI libraries (kind of)


API integrations e.g. Flickr, Google, Twitter


Payment integrations


Authentication & more


Don’t reinvent the wheel

Other Options


Zend

Framework


CakePHP


Symfony


Yii



http://www.phpframeworks.com
/


http://www.phpframeworks.com/top
-
10
-
php
-
frameworks/

Questions?


i.robotham@abdn.ac.uk


01224 437036 (UOA 7036)


@
eyejaynet