0% found this document useful (0 votes)
95 views

EdFinkler-Introduction To CodeIgniter

CodeIgniter is a PHP web application framework that focuses on simplicity and performance. It uses a model-view-controller pattern to organize applications, and provides features like routing, security, and loading of libraries, helpers, and plugins. CodeIgniter applications can be extended through custom libraries, hooks, and by overriding native classes. The document provides an overview of CodeIgniter's structure, URL routing, security measures, and ways to extend its functionality.

Uploaded by

Tania Joy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

EdFinkler-Introduction To CodeIgniter

CodeIgniter is a PHP web application framework that focuses on simplicity and performance. It uses a model-view-controller pattern to organize applications, and provides features like routing, security, and loading of libraries, helpers, and plugins. CodeIgniter applications can be extended through custom libraries, hooks, and by overriding native classes. The document provides an overview of CodeIgniter's structure, URL routing, security measures, and ways to extend its functionality.

Uploaded by

Tania Joy
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Introduction to CodeIgniter

Ed Finkler
[email protected] • funkatron.com

20070914
1
What is CodeIgniter?

• YAPF
(Yet Another PHP Framework)

Ed Finkler <[email protected]>

2
Why care about CI?

• Battle-tested
• Fast
• Adaptable

Ed Finkler <[email protected]>

3
Notable CI features
• Fast
• Compatible with many environments
• Quick to set-up
• Plays well with others
• Focus on simple solutions
• Good docs & community
Ed Finkler <[email protected]>

4
CI structure
index.php
Loaded by browser
Bootstraps everything

system application
base classes & built-in app-specific classes
functionality and functionality

Ed Finkler <[email protected]>

5
CI structure

Ed Finkler <[email protected]>

6
URL structure
domain.com/controller_class/method/data
<?php

class Search extends Controller {

[...]

function retrieve($id)
{
$this->load->database();

[...]
}

}
?>

Ed Finkler <[email protected]>

7
MVC pattern

• Controller Classes
• private methods prefixed with “_”

Ed Finkler <[email protected]>

8
MVC pattern
• Views
• Plain PHP as templating lang

Ed Finkler <[email protected]>

9
MVC pattern

• Views
• Optional template markup

Ed Finkler <[email protected]>

10
MVC pattern

• Models
• Optional
• ActiveRecord pattern available, not required
• Query binding
$sql = "SELECT * FROM some_table WHERE id = ? AND status = ? AND author = ?";
$this->db->query($sql, array(3, 'live', 'Rick'));

Ed Finkler <[email protected]>

11
Helpers
• Procedural funcs, grouped by file
• Mostly for views; available in controllers

Ed Finkler <[email protected]>

12
Plugins
• Single procedural function
• More extensive functionality than helper

Ed Finkler <[email protected]>

13
Loading on-demand

• $this->load->library|view|helper|plugin|...(‘name’);

• Auto-loading set in config/autoload.php

Ed Finkler <[email protected]>

14
CI security

• Not Foolproof (nothing is!)


• Limits allowed chars in URI
• register_globals “forced off”

Ed Finkler <[email protected]>

15
CI security

• Data only passed via POST or COOKIE


• GET query destroyed
• Array keys filtered
• Auto XSS Filtering (must enable)
• Query binding - use it!

Ed Finkler <[email protected]>

16
Extending CI
• The CI Way
• Creating your own libs
• Extend native libs (MY_Email)
• As-is, can’t extend/replace controller or
database classes
• Replacing native libs
• Hooks
Ed Finkler <[email protected]>

17
Extending CI

• The “however the hell you want to do it”


way
• Just require your libs
• Collisions unlikely (not impossible)

Ed Finkler <[email protected]>

18
Example App

• CI + Simplepie + Zend_Json == Web2.0 profit

Ed Finkler <[email protected]>

19
Danke

• codeigniter.com
• Slides will be up at funkatron.com shortly

Ed Finkler <[email protected]>

20

You might also like