• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)
 

Introduction to CodeIgniter (RefreshAugusta, 20 May 2009)

on

  • 12,493 views

I gave this presentation at the monthly RefreshAugusta meeting on 20 May 2009 at The Well in Downtown Augusta.

I gave this presentation at the monthly RefreshAugusta meeting on 20 May 2009 at The Well in Downtown Augusta.

Statistics

Views

Total Views
12,493
Views on SlideShare
5,280
Embed Views
7,213

Actions

Likes
0
Downloads
117
Comments
0

12 Embeds 7,213

http://www.michaelwales.com 7153
http://translate.googleusercontent.com 15
http://192.168.10.3 14
http://www.slideshare.net 10
http://web.archive.org 7
http://michaelwales.com 5
http://www.linkedin.com 3
http://webcache.googleusercontent.com 2
http://www.netvibes.com 1
http://liveweb.archive.org 1
http://feeds.feedburner.com 1
http://theoldreader.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • #1 Google result for “open source PHP framework”
  • Free to downloadCan virtually do anything with framework- Can not create a commercial blogging application
  • EE2 is built on top of the CodeIgniter framework
  • EllisLab supports the company and it’s 11 employees off of ExpressionEngine primarily.CodeIgniter is the foundation of the new version of ExpressionEngine.EllisLab is committed to supporting the framework, it’s not a side project it is the core of their business.
  • In 2001, Rick Ellis started work on a blogging engine for his clients.The first installation of pMachine was for Nancy Sinatra (Frank Sinatra’s daughter).
  • In 2002, pMachine was released.Featured in Mac World and Mac Addict as well as a Blogging book published by McGraw/Hill.Rick Ellis starts developing software full-time.
  • ExpressionEngine succeeds pMachine and is a more fully feature complete Content Management System.ExpressionEngine sees great success within the designer market, on their personal blogs (VeerlePieters, for instance).
  • EllisLab pulls the core code out of ExpressionEngine and refactors into a framework.
  • At SXSW ’08, EllisLab announces ExpressionEngine 2.Derek Allard, Code Architect for EllisLab, announces that ExpressionEngine 2 will run on top of the CodeIgniter framework.Full Circle: CodeIgniter was born from ExpressionEngine and now it is powering ExpressionEngine
  • Benchmarking performed by AvnetLabs w/ eAcceleratoropcode caching10.5x faster than CakePHP, 2.9x faster than Zend Framework (similar configurations / similar functionality)I’ve never seen a benchmark where CodeIgniter didn’t outperform all competitors
  • Statistics dated Oct 08, from nexen.netShows about a 50/50 split between PHP4 and 5 support.No doubt PHP5 has taken the lead by now, but many users still stuck on PHP4.CodeIgniter utilizes PHP5 features/performance-enhancing functionality when present.
  • MySQL is by far the most supported but could switch without the need to completely rewrite code.Supports MySQL, MS SQL, Oracle, PostgreSQL, SQLite and ODBC connectors.ActiveRecord class allows you to think in PHP and generate SQL.
  • Facebook, MySpace,Twitter and other social networks have seen the rise of a new form of worm.These worms are Javascript based, essentially the attacker enters code into a form that your site displays somewhere.This allows the malicious code to run from your domain essentially bypassing all of the domain-lock features Javascript has built-in.At the flick of a boolean variable, CodeIgniter will automatically protect all of your form fields from XSS vulnerabilities.
  • CodeIgniter automatically generates SEO friendly URLsOf course, this is easily overidden: regular expression pattern matching to point to controller/method and pass variables
  • Nearly every CodeIgniter library and helper can be overridden – allowing you to increase functionality.Examples: auto-discovery of partial views, auto-discovery of models, authentication by basing application classes off of my own controller class, which in turns extends the CodeIgniter Controller class
  • RasmusLerdorf at fOScon 08.He gave a presentation pretty much slamming all PHP frameworks. If he had to pick one, it would be CodeIgniter.
  • The model represents our data – in this particular case we are returning data from a database.Could return data from anything – a Web API, an XML file, JSON, etc.
  • All models extends CodeIgniter’s Model class and must call the parent class’ constructor from their own constructor.
  • This function starts building our SQL query by creating the ORDER BY portion.get() will run the query against the posts table, returning 10 results starting at row 0.We also have a get_where() method, that allows you to pass WHERE statements.get() will return all columns, but a select() method is available to define columns if necessary.We use the num_rows() method to return a result object or the FALSE boolean.
  • The controller accepts and handles all user input (URLs, POST/GET requests, etc.)Like the model, a controller extends the CI Controller class.Controllers must call their parent constructor from within their own constructor.index() method is called by default, if a method is not defined in the URL.We load our post model, then call the get_all() method of that model.We then load a view, called home, and pass it our array of variables (in this case, only the posts).
  • Like the model, a controller extends the CI Controller class.Controllers must call their parent constructor from within their own constructor.
  • index() method is called by default, if a method is not defined in the URL.We load our post model, then call the get_all() method of that model.We then load a view, called home, and pass it our array of variables (in this case, only the posts).
  • The view is simply an HTML file with PHP inter-mixed.Logic should be kept to a bare minimum – just echo data in the view.Templating engines can be used and CI even has a Template Parsing class (why would you want to add more processing time)?Notice the lack of the $data variable – within a view, CodeIgniter brings all $data keys (or child objects) up to top-level variables.Normally, we would check for a FALSE value before looping and show a “No Posts” message – lack of space on screen here.
  • Loop through each of the results returned from our database call (which happened in the model).
  • Echo out the title of the post, title was one of the fields within our posts table.
  • Echo out the excerpt of the post, once again a field within our table.
  • Use a CodeIgniter helper to generate a link to read the entire post.First parameter is the URI segments, second is text of the link, third is an optional array of HTML attributes.Slug was a field within our database – CodeIgniter has a helper to autocreate slugs from text.Would use URI routing to process this request and send it to Controller/Method

Introduction to CodeIgniter (RefreshAugusta, 20 May 2009) Introduction to CodeIgniter (RefreshAugusta, 20 May 2009) Presentation Transcript

  • Introduction to 20 May 2009
  •  Open Source PHP Framework <?php $this->load->view(‘about’);
  •  Open Source PHP Framework  Free (as in beer / as in rights) <?php $this->load->view(‘about’);
  •  Open Source PHP Framework  Free (as in beer / as in rights)  The “guts” of ExpressionEngine 2 <?php $this->load->view(‘about’);
  •  Open Source PHP Framework  Free (as in beer / as in rights)  The “guts” of ExpressionEngine 2  Backed by bootstrapped company <?php $this->load->view(‘about’);
  •  ‘01: Rick Ellis develops pMachine <?php $this->load->model(‘event’); $data[‘events’] = $this->event->get_all(); $this->load->view(‘history’, $data);
  •  ‘01: Rick Ellis develops pMachine  ‘02: pMachine publicly released <?php $this->load->model(‘event’); $data[‘events’] = $this->event->get_all(); $this->load->view(‘history’, $data);
  •  ‘01: Rick Ellis develops pMachine  ‘02: pMachine publicly released  ‘04: ExpressionEngine released <?php $this->load->model(‘event’); $data[‘events’] = $this->event->get_all(); $this->load->view(‘history’, $data);
  •  ‘01: Rick Ellis develops pMachine  ‘02: pMachine publicly released  ‘04: ExpressionEngine released  ‘06: CodeIgniter released <?php $this->load->model(‘event’); $data[‘events’] = $this->event->get_all(); $this->load->view(‘history’, $data);
  •  ‘01: Rick Ellis develops pMachine  ‘02: pMachine publicly released  ‘04: ExpressionEngine released  ‘06: CodeIgniter released  ’08: ExpressionEngine 2 demoed at SXSW <?php $this->load->model(‘event’); $data[‘events’] = $this->event->get_all(); $this->load->view(‘history’, $data);
  •  Small footprint 10.5x 2.9x <?php $this->load->model(‘feature’); $data[‘features’] = $this->feature->get_all(); $this->load->view(‘features’, $data);
  •  Small footprint  PHP 4 compatible <?php $this->load->model(‘feature’); $data[‘features’] = $this->feature->get_all(); $this->load->view(‘features’, $data);
  •  Small footprint  PHP 4 compatible  Database abstraction layer <?php $this->load->model(‘feature’); $data[‘features’] = $this->feature->get_all(); $this->load->view(‘features’, $data);
  •  Small footprint  PHP 4 compatible  Database abstraction layer  Global XSS filtering <?php $this->load->model(‘feature’); $data[‘features’] = $this->feature->get_all(); $this->load->view(‘features’, $data);
  •  Small footprint  PHP 4 compatible  Database abstraction layer  Global XSS filtering  SEO friendly URLs example.com/controller/method/var1/var2 <?php $this->load->model(‘feature’); $data[‘features’] = $this->feature->get_all(); $this->load->view(‘features’, $data);
  •  Small footprint  PHP 4 compatible  Database abstraction layer  Global XSS filtering  SEO friendly URLs  Infinitely extensible <?php $this->load->model(‘feature’); $data[‘features’] = $this->feature->get_all(); $this->load->view(‘features’, $data);
  • Rasmus Lerdorf Creator of PHP Infrastructure Architect, Yahoo
  • <?php class Post extends Model { function Post() { parent::Model(); } function get_all() { $this->db->order_by(‘postdate’, ‘DESC’); $query = $this->db->get(‘posts’, 10, 0); if ($query->num_rows() > 0) { return $query->result(); } return FALSE; } }
  • <?php class Post extends Model { function Post() { parent::Model(); } function get_all() { $this->db->order_by(‘postdate’, ‘DESC’); $query = $this->db->get(‘posts’, 10, 0); if ($query->num_rows() > 0) { return $query->result(); } return FALSE; } }
  • <?php class Post extends Model { function Post() { parent::Model(); } function get_all() { $this->db->order_by(‘postdate’, ‘DESC’); $query = $this->db->get(‘posts’, 10, 0); if ($query->num_rows() > 0) { return $query->result(); } return FALSE; } }
  • <?php class Posts extends Controller { function Posts() { parent::Controller(); } function index() { $this->load->model(‘post’); $data[‘posts’] = $this->post->get_all(); $this->load->view(‘home’, $data); } }
  • <?php class Posts extends Controller { function Posts() { parent::Controller(); } function index() { $this->load->model(‘post’); $data[‘posts’] = $this->post->get_all(); $this->load->view(‘home’, $data); } }
  • <?php class Posts extends Controller { function Posts() { parent::Controller(); } function index() { $this->load->model(‘post’); $data[‘posts’] = $this->post->get_all(); $this->load->view(‘home’, $data); } }
  • <!-– html, head, body tag --> <?php foreach($posts as $p): ?> <div class=‚post‛> <h2><?php echo $p->title; ?></h2> <div class=‚excerpt‛> <?php echo $p->excerpt; ?> </div> <p><?php echo anchor($p->id, ‘Read More’); ?></p> </div> <?php endforeach; ?> <!-- /body, /head, /html tags -->
  • <!-– html, head, body tag --> <?php foreach($posts as $p): ?> <div class=‚post‛> <h2><?php echo $p->title; ?></h2> <div class=‚excerpt‛> <?php echo $p->excerpt; ?> </div> <p><?php echo anchor($p->id, ‘Read More’); ?></p> </div> <?php endforeach; ?> <!-- /body, /head, /html tags -->
  • <!-– html, head, body tag --> <?php foreach($posts as $p): ?> <div class=‚post‛> <h2><?php echo $p->title; ?></h2> <div class=‚excerpt‛> <?php echo $p->excerpt; ?> </div> <p><?php echo anchor($p->id, ‘Read More’); ?></p> </div> <?php endforeach; ?> <!-- /body, /head, /html tags -->
  • <!-– html, head, body tag --> <?php foreach($posts as $p): ?> <div class=‚post‛> <h2><?php echo $p->title; ?></h2> <div class=‚excerpt‛> <?php echo $p->excerpt; ?> </div> <p><?php echo anchor($p->id, ‘Read More’); ?></p> </div> <?php endforeach; ?> <!-- /body, /head, /html tags -->
  • <!-– html, head, body tag --> <?php foreach($posts as $p): ?> <div class=‚post‛> <h2><?php echo $p->title; ?></h2> <div class=‚excerpt‛> <?php echo $p->excerpt; ?> </div> <p><?php echo anchor($p->slug, ‘Read More’); ?></p> </div> <?php endforeach; ?> <!-- /body, /head, /html tags --> example.com/refreshaugust-may-2009
  • michaelwales.com Twitter: @walesmd webmaster@michaelwales.com