SlideShare une entreprise Scribd logo
1  sur  23
5 Reasons To Love CodeIgniter
Everyone Loves Their Framework
What Is CodeIgniter? It’s an MVC framework. MVC stands for Model View Controller and it’s a logical way of organizing an application.  Models interact with the database Controllers take care of the logic Views present the output CodeIgniter doesn’t force you to do things this way, it enables you to do so.
Why CodeIgniter? According To Me Most frameworks will help you write better code faster. CodeIgniter will help you do that without forcing you into some intricate, and weird way of doing things. According To EllisLab (creators of CI) “…helps you write kick-ass PHP programs”
Submit URIs To Your Will One of the foundations of CI is “clean URLs”. Nice looking, well organized URLs, without any of the ugliness of query strings. Ugly atlantaphp.org/presenters.php?action=display&name=nic Pretty atlantaphp.org/presenters/display/nic
How Does it Work? It’s a thing of beauty, really. class Presenters extends Controller{	 	function display($var){ 			echo $var; 		} } //Echoes “nic”
Need More Control? Why yes, there’s a class for that atlantaphp.org/archives/show/picture/1234 $this->uri->segment(3); //picture $this->uri->segment(99,0); //Returns 0 instead of FALSE $this->uri->uri_to_assoc(); //[array](‘picture’ => ‘1234’) $this->uri->uri_string(); // /archives/show/picture/1234 $this->uri->total_segments(); //4 There are several more functions to play around with.
Form and Data Validation The Form view <?php echo validation_errors(); ?> <form action="form_test" method="post”> 	<label for="username">Username</label> 	<input type="text" name="username" value="<?php echo set_value('username'); ?>"/> 	<input type="submit" value="Submit" /> </form>
The controller class Form_test extends Controller { 	function index(){ //Index is always the default for the controller 	    $this->load->library('form_validation'); 		   $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]'); 		   if ($this->form_validation->run() == FALSE) 		   {   				 $this->load->view('form_view’); 		   } 		   else 		   { 			   $this->load->view('form_ok'); 		   } 	} }
Other Cool Stuff $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]’); $this->form_validation->set_rules('username', 'Username', ‘check_duplicate'); $this->form_validation->set_error_delimiters(’<span class="error">', '</span>'); <?php echo form_error('username'); ?> set_select() set_checkbox() and set_radio()
Security and XSS Filtering CodeIgniter does a few things right off the bat. Destroys $_GET. Destroys all global variables (although register_globals is off by default since 4.2.0) Filters $_POST and $_COOKIE array keys, allowing only alphanumeric characters plus “~%.:_” XSS filtering can be enabled globally or called by a function.
XSS Filtering Can be enabled two ways Locally:  $data = $this->input->xss_clean($data); $img_file = this->input->xss_clean($file, TRUE) //Checks image files for XSS attacks $name = $this->input->post(‘name’, TRUE) //$_POST[‘name’] Globally (in the config file): config['global_xss_filtering'] = TRUE;
Database Security There are many ways to sanitize your queries, CodeIgniter offers a few. Bindings $sql = “SELECT FROM members WHERE name = ?”; $this->db->query($sql, array(‘nic’)); Using the Active Record class takes care of security aspects $this->db->where(’name', $name); $this->db->update(’users', $data); Other Functions $this->db->protect_identifiers('table_name'); $this->db->escape($data); $this->db->escape_str($data); $this->db->escape_like_str($data);
Pagination It’s always an issue to display large data sets in an orderly manner. CodeIgniter provides a way to set up proper pagination in a few lines of code. In the controller $this->load->library('pagination'); $config['base_url'] = 'http://atlantaphp.org/pager/index/'; $config['total_rows'] = 200; $config['per_page'] = 10;  $this->pagination->initialize($config); In the view echo $this->pagination->create_links();
Image Manipulation CodeIgniter does four image processing types very easily: crop*, resize, rotate, watermark. Create a thumbnail $config['image_library'] = 'gd2'; $config['source_image']	= 'assets/images/elephpant.jpg'; $config['create_thumb'] = TRUE; $config['maintain_ratio'] = TRUE; //Saved from a P.I.T.A $config['width']	= 75; $config['height’] = 50; $this->load->library('image_lib', $config);  $this->image_lib->resize(); *Never got crop to work 
Rotate $config['image_library'] = 'gd2'; $config['source_image']	= 'assets/images/elephpant.jpg'; $config['new_image']	= 'assets/images/elephpant_rotate.jpg';		 $config['rotation_angle'] = '180'; $config['rotation_angle'] = 'hor'; $this->load->library('image_lib', $config);  $this->image_lib->rotate;
Watermark $config['source_image']	= 'assets/images/elephpant.jpg'; $config['new_image']	= 'assets/images/elephpant_wm.jpg';		 $config['wm_text'] = 'ATLANTAPHP ROCKS!'; $config['wm_type'] = 'text'; $config['wm_font_path'] = 'assets/images/tesox.ttf'; $config['wm_font_size']	= '25'; $config['wm_font_color'] = 'ffffff'; $config['wm_vrt_alignment'] = 'top'; $config['wm_hor_alignment'] = 'center'; $config['wm_padding'] = '10'; $this->load->library('image_lib', $config);  $this->image_lib->watermark();
Errors and Cleaning House The image manipulation functions return boolean values, so you can display errors on FALSE if( ! $this->image_lib->watermark()) {	 			echo $this->image_lib->display_errors();	 }	 Clean up after yourself! $this->image_lib->clear(); //Clears the config values
More To Love Extremely easy to set up. Intuitive (i.e. short learning curve.) It’s open source and has a permissive license. Extend existing libraries and add your own. Load only what you use. The community is outstanding.  It has a Smiley helper!
Resources CodeIgniter User Guide http://codeigniter.com/user_guide/ CodeIgniter Forums http://codeigniter.com/forums/ CodeIgniter From Scratch (Nettuts video series) http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-1/ Forrst – Not a CI dedicated site, but many CI users belong to the community, and the service itself is built on CI. http://forrst.com/

Contenu connexe

Tendances

Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecJoseph Wilk
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperfNew Relic
 
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)Wim Godden
 
Creating fast, dynamic ACLs in Zend Framework
Creating fast, dynamic ACLs in Zend FrameworkCreating fast, dynamic ACLs in Zend Framework
Creating fast, dynamic ACLs in Zend FrameworkWim Godden
 
Telling Stories With RSpec
Telling Stories With RSpecTelling Stories With RSpec
Telling Stories With RSpecrahoulb
 
Presentation.Key
Presentation.KeyPresentation.Key
Presentation.Keyguesta2b31d
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014Mike Schinkel
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Mike Schinkel
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With CucumberSean Cribbs
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 WebJoseph Wilk
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?brynary
 
Have Better Toys
Have Better ToysHave Better Toys
Have Better Toysapotonick
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionPaul Irish
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkVance Lucas
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Ted Kulp
 
Method based views in django applications
Method based views in django applicationsMethod based views in django applications
Method based views in django applicationsGary Reynolds
 

Tendances (20)

Outside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and RspecOutside-in Development with Cucumber and Rspec
Outside-in Development with Cucumber and Rspec
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperf
 
GAEO
GAEOGAEO
GAEO
 
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
Creating fast, dynamic ACLs in Zend Framework (Zend Webinar)
 
Creating fast, dynamic ACLs in Zend Framework
Creating fast, dynamic ACLs in Zend FrameworkCreating fast, dynamic ACLs in Zend Framework
Creating fast, dynamic ACLs in Zend Framework
 
Telling Stories With RSpec
Telling Stories With RSpecTelling Stories With RSpec
Telling Stories With RSpec
 
Presentation.Key
Presentation.KeyPresentation.Key
Presentation.Key
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
 
Cucumber Ru09 Web
Cucumber Ru09 WebCucumber Ru09 Web
Cucumber Ru09 Web
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
Have Better Toys
Have Better ToysHave Better Toys
Have Better Toys
 
jQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & CompressionjQuery Anti-Patterns for Performance & Compression
jQuery Anti-Patterns for Performance & Compression
 
Plugins unplugged
Plugins unpluggedPlugins unplugged
Plugins unplugged
 
Bullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-FrameworkBullet: The Functional PHP Micro-Framework
Bullet: The Functional PHP Micro-Framework
 
Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101Geek Moot '09 -- Smarty 101
Geek Moot '09 -- Smarty 101
 
Method based views in django applications
Method based views in django applicationsMethod based views in django applications
Method based views in django applications
 
Bare acl
Bare aclBare acl
Bare acl
 

Similaire à I Love codeigniter, You?

Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplicationolegmmiller
 
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Compare Infobase Limited
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress DeveloperJoey Kudish
 
Coder Presentation Szeged
Coder Presentation SzegedCoder Presentation Szeged
Coder Presentation SzegedDoug Green
 
Baking With Cake Php
Baking With Cake PhpBaking With Cake Php
Baking With Cake Phpvalberg
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolGordon Forsythe
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)andrewnacin
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsJohn Brunswick
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API DevelopmentAndrew Curioso
 
Advanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsAdvanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsandrewnacin
 
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in SugarSugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in SugarJohn Mertic
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kianphelios
 

Similaire à I Love codeigniter, You? (20)

Php frameworks
Php frameworksPhp frameworks
Php frameworks
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Framework
FrameworkFramework
Framework
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Create a web-app with Cgi Appplication
Create a web-app with Cgi AppplicationCreate a web-app with Cgi Appplication
Create a web-app with Cgi Appplication
 
Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation Zend - Installation And Sample Project Creation
Zend - Installation And Sample Project Creation
 
Becoming a better WordPress Developer
Becoming a better WordPress DeveloperBecoming a better WordPress Developer
Becoming a better WordPress Developer
 
Coder Presentation Szeged
Coder Presentation SzegedCoder Presentation Szeged
Coder Presentation Szeged
 
What's New in ZF 1.10
What's New in ZF 1.10What's New in ZF 1.10
What's New in ZF 1.10
 
Baking With Cake Php
Baking With Cake PhpBaking With Cake Php
Baking With Cake Php
 
Zend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_ToolZend Framework 1.9 Setup & Using Zend_Tool
Zend Framework 1.9 Setup & Using Zend_Tool
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
Boston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on RailsBoston Computing Review - Ruby on Rails
Boston Computing Review - Ruby on Rails
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Cakefest 2010: API Development
Cakefest 2010: API DevelopmentCakefest 2010: API Development
Cakefest 2010: API Development
 
Advanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsAdvanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIs
 
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in SugarSugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
 
สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1สปริงเฟรมเวิร์ค4.1
สปริงเฟรมเวิร์ค4.1
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
P H P Part I I, By Kian
P H P  Part  I I,  By  KianP H P  Part  I I,  By  Kian
P H P Part I I, By Kian
 

Dernier

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Dernier (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

I Love codeigniter, You?

  • 1. 5 Reasons To Love CodeIgniter
  • 3. What Is CodeIgniter? It’s an MVC framework. MVC stands for Model View Controller and it’s a logical way of organizing an application. Models interact with the database Controllers take care of the logic Views present the output CodeIgniter doesn’t force you to do things this way, it enables you to do so.
  • 4. Why CodeIgniter? According To Me Most frameworks will help you write better code faster. CodeIgniter will help you do that without forcing you into some intricate, and weird way of doing things. According To EllisLab (creators of CI) “…helps you write kick-ass PHP programs”
  • 5. Submit URIs To Your Will One of the foundations of CI is “clean URLs”. Nice looking, well organized URLs, without any of the ugliness of query strings. Ugly atlantaphp.org/presenters.php?action=display&name=nic Pretty atlantaphp.org/presenters/display/nic
  • 6. How Does it Work? It’s a thing of beauty, really. class Presenters extends Controller{ function display($var){ echo $var; } } //Echoes “nic”
  • 7. Need More Control? Why yes, there’s a class for that atlantaphp.org/archives/show/picture/1234 $this->uri->segment(3); //picture $this->uri->segment(99,0); //Returns 0 instead of FALSE $this->uri->uri_to_assoc(); //[array](‘picture’ => ‘1234’) $this->uri->uri_string(); // /archives/show/picture/1234 $this->uri->total_segments(); //4 There are several more functions to play around with.
  • 8. Form and Data Validation The Form view <?php echo validation_errors(); ?> <form action="form_test" method="post”> <label for="username">Username</label> <input type="text" name="username" value="<?php echo set_value('username'); ?>"/> <input type="submit" value="Submit" /> </form>
  • 9. The controller class Form_test extends Controller { function index(){ //Index is always the default for the controller $this->load->library('form_validation'); $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]'); if ($this->form_validation->run() == FALSE) { $this->load->view('form_view’); } else { $this->load->view('form_ok'); } } }
  • 10.
  • 11. Other Cool Stuff $this->form_validation->set_rules('username', 'Username', 'trim|required|min_length[5]’); $this->form_validation->set_rules('username', 'Username', ‘check_duplicate'); $this->form_validation->set_error_delimiters(’<span class="error">', '</span>'); <?php echo form_error('username'); ?> set_select() set_checkbox() and set_radio()
  • 12. Security and XSS Filtering CodeIgniter does a few things right off the bat. Destroys $_GET. Destroys all global variables (although register_globals is off by default since 4.2.0) Filters $_POST and $_COOKIE array keys, allowing only alphanumeric characters plus “~%.:_” XSS filtering can be enabled globally or called by a function.
  • 13. XSS Filtering Can be enabled two ways Locally: $data = $this->input->xss_clean($data); $img_file = this->input->xss_clean($file, TRUE) //Checks image files for XSS attacks $name = $this->input->post(‘name’, TRUE) //$_POST[‘name’] Globally (in the config file): config['global_xss_filtering'] = TRUE;
  • 14. Database Security There are many ways to sanitize your queries, CodeIgniter offers a few. Bindings $sql = “SELECT FROM members WHERE name = ?”; $this->db->query($sql, array(‘nic’)); Using the Active Record class takes care of security aspects $this->db->where(’name', $name); $this->db->update(’users', $data); Other Functions $this->db->protect_identifiers('table_name'); $this->db->escape($data); $this->db->escape_str($data); $this->db->escape_like_str($data);
  • 15. Pagination It’s always an issue to display large data sets in an orderly manner. CodeIgniter provides a way to set up proper pagination in a few lines of code. In the controller $this->load->library('pagination'); $config['base_url'] = 'http://atlantaphp.org/pager/index/'; $config['total_rows'] = 200; $config['per_page'] = 10; $this->pagination->initialize($config); In the view echo $this->pagination->create_links();
  • 16.
  • 17. Image Manipulation CodeIgniter does four image processing types very easily: crop*, resize, rotate, watermark. Create a thumbnail $config['image_library'] = 'gd2'; $config['source_image'] = 'assets/images/elephpant.jpg'; $config['create_thumb'] = TRUE; $config['maintain_ratio'] = TRUE; //Saved from a P.I.T.A $config['width'] = 75; $config['height’] = 50; $this->load->library('image_lib', $config); $this->image_lib->resize(); *Never got crop to work 
  • 18. Rotate $config['image_library'] = 'gd2'; $config['source_image'] = 'assets/images/elephpant.jpg'; $config['new_image'] = 'assets/images/elephpant_rotate.jpg'; $config['rotation_angle'] = '180'; $config['rotation_angle'] = 'hor'; $this->load->library('image_lib', $config); $this->image_lib->rotate;
  • 19. Watermark $config['source_image'] = 'assets/images/elephpant.jpg'; $config['new_image'] = 'assets/images/elephpant_wm.jpg'; $config['wm_text'] = 'ATLANTAPHP ROCKS!'; $config['wm_type'] = 'text'; $config['wm_font_path'] = 'assets/images/tesox.ttf'; $config['wm_font_size'] = '25'; $config['wm_font_color'] = 'ffffff'; $config['wm_vrt_alignment'] = 'top'; $config['wm_hor_alignment'] = 'center'; $config['wm_padding'] = '10'; $this->load->library('image_lib', $config); $this->image_lib->watermark();
  • 20. Errors and Cleaning House The image manipulation functions return boolean values, so you can display errors on FALSE if( ! $this->image_lib->watermark()) { echo $this->image_lib->display_errors(); } Clean up after yourself! $this->image_lib->clear(); //Clears the config values
  • 21.
  • 22. More To Love Extremely easy to set up. Intuitive (i.e. short learning curve.) It’s open source and has a permissive license. Extend existing libraries and add your own. Load only what you use. The community is outstanding. It has a Smiley helper!
  • 23. Resources CodeIgniter User Guide http://codeigniter.com/user_guide/ CodeIgniter Forums http://codeigniter.com/forums/ CodeIgniter From Scratch (Nettuts video series) http://net.tutsplus.com/articles/news/codeigniter-from-scratch-day-1/ Forrst – Not a CI dedicated site, but many CI users belong to the community, and the service itself is built on CI. http://forrst.com/

Notes de l'éditeur

  1. Devotion to framewroks is almost like sports teams or religion. In truth you should pick the one that better suits your needs and style, not the one that has the most hype.
  2. How many of you tried to start using a framework and were frustrated by how it forced you to change your coding style?
  3. The controller will interpret the first segment after the controller name (the second segment) as a variable passed to the function. You can pass as many variables as you need using this method, but careful, if you require the variables and they aren’t present you’ll get an error as usual.Explain how to pass a second var
  4. Enter the URI class. The URI class let’s you pick and choose from the URI segments, and do other cool manipulations. The URI class is autoloaded, so you can call it without declaring it first.By default uri_to_assoc starts at segment 3 assuming the first two are controller/function
  5. Who hates validating forms? It’s tedious, and error prone. CI comes with a bazillion functions to help you deal with forms, but here are the basics.This is a normal form with two added functions. Validation_errors() and set_value()
  6. What’s happening here? When we call the form controller it loads the index function by default.We load the form_validation library.Set validation rules for the username field. Notice the field name, human-friendly name, validation rules (these are built in)The first time the controller runs the form hasn’t been submitted, so the validation returns FALSE and loads the ‘form_view’ view
  7. Notice the human readable name is used, the error message is built in although it can be customized. The previous form entry is auto-populated.
  8. Data prepping, Use any native PHP function that takes a single argument.Run your own validation functionsAdd your own delimiters. By default each error message is wrapped in &lt;p&gt; tagsDisplay errors individually as opposed to all in a list. This could allow you putting the error next to the field.No only text fields can be auto-populated, select, checkbox and radio inputs can be returned to the state they were submitted too.
  9. CI doesn’t use $_GET at all (it can be tricked into doing so, but it’s unnecessary)If you are a knuclehead and turned it on for some reason, it won’t matterthe values are escaped when interfacing with the DB and through the XSS filterThere’s overhead involved in using XSS filter globally, I didn’t benchmark it or notice it.
  10. If you want to learn how the inner workings are, check the input class
  11. Bindings automatically escape queriesActive record takes care of all securityProtect identifiers puts backticks on field and table namesEscape like is for LIKE db calls
  12. Base URL is the page where the links need to be directed toTotal rows is usually determined dynamically based on the number of items to display. Presumably by querying the database and finding out the size of the result set.Per page is the number of items to showThis is the minimum configuration required
  13. Robert Swarthout presented image manipulation libraries back in February, so if you saw that, this is a nice continuation.
  14. During development I like to add FirePHP, autoload it and use it as $this-&gt;firephp-&gt;log(‘output to console’)