Benefits of the CodeIgniter Framework

34
CodeIgniter PHP Framework Toby Beresford [email protected]

description

Toby Beresford's slides from the PHP London Conference 08 on CodeIgniter - part of a comparison with Zend and Symfony

Transcript of Benefits of the CodeIgniter Framework

Page 1: Benefits of the CodeIgniter Framework

CodeIgniter PHP Framework

Toby Beresford

[email protected]

Page 2: Benefits of the CodeIgniter Framework

Content

• Bio• Benefits• Why Frameworks• MVC• Demo• Links

Page 3: Benefits of the CodeIgniter Framework

Toby Bio• 12 years – professional Web App Development

• 5 years - Lotus Domino• 7 years – PHP• 8 months - CodeIgniter

• Toby Beresford Applications Ltd

• Platform applications• Facebook• Bebo, Myspace et al.

• Clients• Sky News, Last.fm, Comic Relief, VideoJug, AfffiliateWindow, .name registry….

[email protected] / www.tobyberesford.com

• h www.facebook.com/pages/Toby-Beresford-Applications/6164004474

Page 4: Benefits of the CodeIgniter Framework

Benefits of CI• Small

• Fast

• Simple

• Customer ready– a sys admin can install the CI framework in a few minutes– great documentation means easy hand over: new developers just learn the

framework not your home grown MVC code

• Great for mash-up apps using multiple platforms – eg. Facebook apps

• Cleaner code

Page 5: Benefits of the CodeIgniter Framework

Why FrameworksNo framework

Framework

Me and my framework

Framework

Platform API

Me, my framework anda Platform API

Page 6: Benefits of the CodeIgniter Framework

MVCView (views/frog_count.php)

<html><body>

<h1> You’ve <?=$froggies;?> items in list</h1></body>

</html>

Controller (controllers/my_controller.php)function total_frogs () {

$this->load->model(“frogs”);$number_of_frogs = $this->frogs->count_frogs();$data[‘froggies’] = $number_of_frogs;$this->load->view(“frog_view”, $data);

}

Model (models/frogs.php)function count_frogs() {

$this->db->where(“type”,”frog”);$this->db->from(“animals”);$query = $this->db->get();Return $query->num_rows();}

Model

View

Controller

Page 7: Benefits of the CodeIgniter Framework

How to run a CI method• http://www.my_server.com/index.php/my_controller/my_frogs

Where you’ve installed CI

Your main controller file:System/application/controllers/my_controller.php

The name of a method in your controller

Page 8: Benefits of the CodeIgniter Framework

Download from www.codeigniter.com

Page 9: Benefits of the CodeIgniter Framework

Upload to your server

Page 10: Benefits of the CodeIgniter Framework

See the welcome screen

Page 11: Benefits of the CodeIgniter Framework

Create your database

Page 12: Benefits of the CodeIgniter Framework

Configure CodeIgniter Base URL

Page 13: Benefits of the CodeIgniter Framework

Configure Database Connection

Page 14: Benefits of the CodeIgniter Framework

Create a controller

Page 15: Benefits of the CodeIgniter Framework

Add the view

Page 16: Benefits of the CodeIgniter Framework

Try it

Page 17: Benefits of the CodeIgniter Framework

Send variables to the view via an array

VIEW

CONTROLLER

Page 18: Benefits of the CodeIgniter Framework

And…

Page 19: Benefits of the CodeIgniter Framework

Model: Get item

• Uses ActiveRecord

Page 20: Benefits of the CodeIgniter Framework

Model: Put Item

Page 21: Benefits of the CodeIgniter Framework

Model: Get all

Page 22: Benefits of the CodeIgniter Framework

Model: Delete Item

Page 23: Benefits of the CodeIgniter Framework

Controller: Add

Page 24: Benefits of the CodeIgniter Framework

View: Add/Edit

Page 25: Benefits of the CodeIgniter Framework

User Interface: Add

Page 26: Benefits of the CodeIgniter Framework

Controller: Save

Page 27: Benefits of the CodeIgniter Framework

Controller: Edit

Page 28: Benefits of the CodeIgniter Framework

User Interface: Edit

Page 29: Benefits of the CodeIgniter Framework

Controller: List all

Page 30: Benefits of the CodeIgniter Framework

Views: List

• Note we can use ordinary PHP in the views, no template language to learn

Page 31: Benefits of the CodeIgniter Framework

User Interface: List

Page 32: Benefits of the CodeIgniter Framework

Class Libraries and HelpersHelper ReferenceArray Helper Cookie Helper Date Helper Directory Helper Download Helper Email Helper File Helper Form Helper HTML Helper Inflector Helper Path Helper Security Helper Smiley Helper String Helper Text Helper Typography Helper URL Helper XML Helper

Class ReferenceBenchmarking Class Calendaring Class Config Class Database Class Email Class Encryption Class File Uploading Class FTP Class HTML Table Class Image Manipulation Class Input and Security Class Loader Class Language Class Output Class

Pagination Class Session Class Trackback Class Template Parser Class Unit Testing Class URI Class User Agent Class Validation Class XML-RPC Class Zip Encoding Class

Page 33: Benefits of the CodeIgniter Framework

Summary

• CI is fast to run, light to deploy and easy to learn

• Great for mash-up applications in the platform world– Wishlist = Eg. AffiliateWindow retailer list API,

product API, Facebook UI, Facebook User tables, + PayPal mass pay for commissions

Page 34: Benefits of the CodeIgniter Framework

Useful links• www.codeigniter.com– User manual, community forums, releases

• www.kohanaphp.com – PHP5 CodeIgniter fork

• www.phpframeworks.info – All the frameworks side by side

• www.people4web2.com– Contractor site with a skills category for the

major PHP Frameworks• LondonGarage06.eventbrite.com– Facebook Developer Garage – 5th March

• Questions? – [email protected]