CodeIgniter-OCPHP-March2010 - Meetup

101 downloads 48 Views 7MB Size Report
PyroCMS (pyrocms.com). ▫ Codefight CMS (codefight.org). ▫ Ionize CMS ( ionizecms.com). ▫ Fuel CMS (getfuelcms.com). ▫ Directories. ▫ Codeigniter Resources ...
Kon Wilms OCPHP March 2011

Introduction

Overview §  A fast, flexible, lightweight, concise, mature and fully documented MVC framework §  Excellent backward compatibility §  Distributed as open source (pseudo-BSD) §  Majority of modules are BSD/GPL §  Fixed release cycles §  Backed by an active community §  Needs a webserver (Apache, IIS, NGINX, …), PHP 5.1.6+, optionally a DB

Internals § 

MVC with singleton loader

§ 

Config, Loader, Router, Cache, Helper, Driver, URI, Hook & Class modules

§ 

Extend via MY_, Libraries (incl. external), Helpers

§ 

Super object ( &get_instance() )

§ 

No strict rule enforcement

Basics § 

Segment based URLs www.site.com/class/function/param/param www.site.com/index.php/controller/function/param

§ 

Controllers $this->load->model(‘customers’); $this->load->view(‘header’); $this->load->helper(‘url’’); If (! $this->auth->logged_in() ) … redirect(‘url’,’refresh)’;

Input § 

Post, (GET) $this->input->post(‘name’);

§ 

Form Validation $this->form_validation->set_rules(‘name’,’Name, ‘required’, myfunc); if ( $this->form_validation->run() == FALSE) … $this->load->view(‘error’);

Processing § 

Models(DB w/ ActiveRecord) $this->load->database(); $query = $this->db->select(‘name’) ->from(‘users’) ->where(‘id’,1) ->limit(1) ->get();

return $query->row(); return $query->row_array();

Rendering § 

Output $data['page_title'] = 'Your title'; $this->load->view('header’, $data); $this->load->view('menu'); $this->load->view(’page’); $this->load->view('footer'); $this->output->set_header("HTTP/1.0 200 OK");

§ 

View

Comparisons § 

Zend (Size, Speed, Complexity)

§ 

CakePHP (Autogen, Speed)

§ 

Variations (Fuel, Forrst, Kohana)

§ 

Symphony (AJAX, Size, Speed, Complexity, Autogen)

§ 

Drupal (Management, not a framework)

§ 

Yii (Backward compatibility, Autogen)

§ 

LightVC (Apples & Oranges)

Selection § 

§ 

Advantages § 

Works well on any size site

§ 

Light, flexible, well documented

§ 

Two-way exponential learning/development curve

§ 

Try before you buy

§ 

Easy hand-off

§ 

Scales to Mojomotor, Expressionengine

Disadvantages § 

Use case matches an existing CMS or off the shelf product

§ 

Investment in existing framework

Installation

Deployment §  Getting Started § 

Site Conversion

§  ‘Real world’ § 

SetTopBox Management UI

§ 

SMS/MMS Mobile Backend

§ 

K-12 Video Replication System

§ 

Medical Distance Learning System

§ 

Content Delivery Network Backend & Admin

§ 

Datacenter Backend & Admin

Extending §  § 

Authentication - ION Auth RBAC - Zend ACL

§ 

Templating - Template Library

§ 

Asset management - Carabiner

§  § 

JS/CSS - Minify CSS, JSMin ORM - DataMapper OZE, Doctrine

§ 

Debugging - Debug Toolbar

§ 

CRUD - CrudIgniter

§ 

AJAX, Backend, Validation, HMVC - Write your own

§ 

Unit Testing - Toast

Performance Tips §  I/O Reduction §  Profiling §  ActiveRecord vs ORM §  View, Ajax Caching §  Internal vs External Caching §  Short circuiting models and views §  Code faster

Gotchas §  Sessions §  Front Controller §  Application and System folders §  DB Caching §  Dynamic caching §  Design pattern considerations

Advanced Topics §  Node.js §  MongoDB / other NoSQL §  Pure socket services such as SNMP §  Shopping cart systems §  Desktop clients consuming CI services §  Multiple applications

Resources § 

'Official’ § 

§ 

§ 

§ 

Mojomotor, Expressionengine (ellislab.com)

CMS §  § 

PyroCMS (pyrocms.com) Codefight CMS (codefight.org)

§  § 

Ionize CMS (ionizecms.com) Fuel CMS (getfuelcms.com)

Directories § 

Codeigniter Resources (codeigniterdirectory.com)

§ 

Sparks (getsparks.org)

Online Tutorials § 

CI Forums, Youtube, Vimeo, NetTuts, etc.

Demo

Overview § 

Portal for major west coast data center

§ 

Codeigniter, Apache, Memcache

§ 

44k LOC, 12 models, 11 libraries, 4 helpers, 3 MY_, 24 tables

§ 

User & Admin sites (MY_Router)

§ 

Jquery, Datatables JS Obfuscation & Highcharts integration

§ 

Customers, Ops, Security, Admins, Facilities RBAC (inc. Theme)

§ 

Custom backend (SNMP, binary objects, API)

§ 

Cron jobs for heavy lifting (daily 95th)

§ 

Targeting IE, FF, Chrome (& Mobile Safari)

§ 

4 months, 1 developer, 1 designer

Topology Browser HTTP

AJAX

Application Server MySQL DB

Codeigniter

Apache

Memcache

HTTP Statistics Server Daemon

Binary DB

SNMP Hosts SNMP

Questions? [email protected]