introduction to ci
DESCRIPTION
CI is very powerfulTRANSCRIPT
![Page 4: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/4.jpg)
Ed Finkler <[email protected]>
Notable CI features
• Fast
• Compatible with many environments
• Quick to set-up
• Plays well with others
• Focus on simple solutions
• Good docs & community
4
![Page 5: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/5.jpg)
Ed Finkler <[email protected]>
CI structureindex.php
Loaded by browserBootstraps everything
system
base classes & built-in functionality
application
app-specific classes and functionality
5
![Page 7: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/7.jpg)
Ed Finkler <[email protected]>
URL structuredomain.com/controller_class/method/data
<?php
class Search extends Controller {
[...]
function retrieve($id)
{
$this->load->database();
[...]
}
}
?>
7
![Page 8: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/8.jpg)
Ed Finkler <[email protected]>
MVC pattern
• Controller Classes
• private methods prefixed with “_”
8
![Page 11: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/11.jpg)
Ed Finkler <[email protected]>
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'));
11
![Page 12: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/12.jpg)
Ed Finkler <[email protected]>
Helpers
• Procedural funcs, grouped by file
• Mostly for views; available in controllers
12
![Page 13: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/13.jpg)
Ed Finkler <[email protected]>
Plugins
• Single procedural function
• More extensive functionality than helper
13
![Page 14: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/14.jpg)
Ed Finkler <[email protected]>
Loading on-demand
• $this->load->library|view|helper|plugin|...(‘name’);
• Auto-loading set in config/autoload.php
14
![Page 15: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/15.jpg)
Ed Finkler <[email protected]>
CI security
• Not Foolproof (nothing is!)
• Limits allowed chars in URI
• register_globals “forced off”
15
![Page 16: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/16.jpg)
Ed Finkler <[email protected]>
CI security
• Data only passed via POST or COOKIE
• GET query destroyed
• Array keys filtered
• Auto XSS Filtering (must enable)
• Query binding - use it!
16
![Page 17: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/17.jpg)
Ed Finkler <[email protected]>
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
17
![Page 18: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/18.jpg)
Ed Finkler <[email protected]>
Extending CI
• The “however the hell you want to do it” way
• Just require your libs
• Collisions unlikely (not impossible)
18
![Page 20: Introduction to CI](https://reader036.vdocument.in/reader036/viewer/2022062316/568bd7671a28ab20349f9b92/html5/thumbnails/20.jpg)
Ed Finkler <[email protected]>
Danke
• codeigniter.com
• Slides will be up at funkatron.com shortly
20