SlideShare une entreprise Scribd logo
1  sur  36
Télécharger pour lire hors ligne
CodeIgniter
A brief introduction
https://github.com/bcit-ci/CodeIgniter
http://www.codeigniter.com/
What is it?
CI is a HMVC framework for rapid PHP web application
development.
It’s focused on performance, ease of use and minimal
configuration.
MVC pattern is encouraged but not enforced.
What is it?
It has been mantained by EllisLab until 2014 ( http:
//ellislab.com/ ) . Since then the code is mantained by
British Columbia Institute of Technology ( http://bcit.ca/ )
Find the contributors list on the GitHub project page:
https://github.com/bcit-
ci/CodeIgniter/graphs/contributors
Why using it
● Flexible and easy to extend
● Lightweight and performant
● Noob friendly
● Minimal configuration
● It can use templating engines, but doesn’t need one
● VERY well documented
● CI Sparks / Composer
● Active community
Main features
● HMVC architecture
● Query-builder database support
● Drivers for main DBMS systems (MySQL,
MS SQL Server, Postgres, Oracle etc...)
● CSRF and XSS Filtering
● Session management
● Benchmarking
Main features
● Image manipulation (requires GD, ImageMagick
or NetPBM)
● Email library
● Uploading
● Caching
● CLI interface
● Internationalization
● … too many to be listed here.
Architectural goals
● Dynamic instantiation: libraries and helpers are loaded
by controllers on demand when they are needed, keeping
the system light and reactive
● Components singularity: each class and its functions are
highly autonomous in order to allow maximum usefulness
● Loose coupling: each component minimizes its reliance
on other components, becoming more reusable.
Requirements
● PHP 5.2.4 (5.4 is recommended)
● A Web Server
Remind that, as of PHP 5.4, the interpreter
provides a built-in web server to test your
applications. So you do not really need a stand
alone web server to start developing.
application/config/config.php holds most of the
configuration you need to start developing your
application, such as base_url (e.g. http://google.
com/, if Google was written with CI), URLs suffixes,
default charsets, locales, hooks configuration,
Composer integration and much more.
Basic configuration
Routing & Controllers
Preliminar note: CI provides a index.php script which triggers the
framework lifecycle for each request.
To remove index.php from URL and to route every request to it, you can
use mod_rewrite on Apache like this https://gist.github.
com/sixpounder/c61e660b43c0aa2b9356
For PHP builtin server look at this GIST https://gist.github.
com/sixpounder/6758cddd83330125bc10
From now on we assume index.php to be removed from URLs.
Routing & Controllers
A request lifecycle in CI
Routing & Controllers
CI URLs are basically query string arguments to
index.php. They are made of URI segments that
represent (by default, but this can be changed in
application/config/config.php by defining custom
routes) the controller and the method
responsible for serving a request mapped on
that specific URL.
Routing & Controllers
example.com/news/article/ID
● The first segment represents the controller class to be
invoked
● The second segment represents the controller instance
method that will be executed (assuming index if not
specified)
● The third (and any further) segment represents an
additional parameter that will be passed to the
controller method as an argument.
Routing & Controllers
● These URLs are SEO-friendly!
● You can organize controllers in sub folders. In this case,
the initial URI segments will represent your folder
structure.
● Classic query strings are available
● You can add URLs suffixes
● You can define overrides, custom URI routings and the
default controller in application/config/routes.php
Routing & Controllers
Controller classes extend CI_Controller and must be
placed in application/controllers. Class name must have
its first letter capitalized and it must match the file
name.
/* application/controllers/Article.php */
class Article extends CI_Controller { … }
Models are classes that interacts with your
database. CI doesn’t provide an ORM like
Rails Active Record, rather it provides a
Query Builder that builds queries by
masking the underlying physical DBMS
implementation.
Models
Models
● Models should be indepent from the components
that use them
● Query Builder supports transactions
● Database Forge Class can be used to manage the
physical structure of your database (so you do not
have the responsability to do so!)
● Support for migrations (by extending CI_Migration)
Models
To load and use a model inside a controller:
$this->load->model(‘model_name’);
Models must be placed in application/models. Classes
and file names must have their first letter capitalized
and the rest of the name lowercase. They must extend
CI_Model.
Views & Templating
CI’s core provides different ways of sending
an output to a client, like basic view
rendering, simple template parsing and
direct output control. All these methods are
wrapped into core libraries.
Views & Templating
View rendering
A view is simply a web page, or a page fragment, like a header, footer,
sidebar, etc. In fact, views can flexibly be embedded within other views
(within other views, etc., etc.) if you need this type of hierarchy.
Views are stored by default in application/views directory and have .php
extension (unless you need something different, eg. if you are using twig).
A controller can render a view by loading it like this:
$this->load->view(‘viewname’);
Views & Templating
View rendering
Data is passed from the controller to the view by way of
an array or an object in the second parameter of the
view loading method.
$data = array('title' => 'My Title','heading' => 'My Heading','message' => 'My
Message');
$this->load->view('blogview', $data);
Views & Templating
View rendering
A third boolean argument may be provided to the view
loader. If it is present and its value is TRUE the method
returns the string representation of the finalized view.
This can be usefull for templating purposes.
$data = array('title' => 'My Title','heading' => 'My Heading','body' => 'Article
body');
var $content = $this->load->view('article', $data, TRUE);
Views & Templating
Output Library
The Output Library is used under-the-hood by the view
loader to finalize the output before sending it to the
client. It can be directly used, for instance, to send a
JSON output if you are dealing with a REST API, or a file’s
content if you are writing a file server and so on.
Views & Templating
JSON example
$this->output->set_content_type('application/json')->set_output(json_encode(array
('foo' => 'bar')));
Sending an image
$this->output->set_content_type('jpeg')->set_output(file_get_contents
('files/something.jpg'));
HINT: The _display() method is called automatically at the end of script execution, you won’t need
to call it manually unless you are aborting script execution using exit() or die() in your code.
Calling it without aborting script execution will result in duplicate output.
Views & Templating
Template Parser
The Template Parser Library can parse simple templates
by operating basic substitutions of pseudo-variables
contained in your views.
Pseudo variables must be enclosed in braces.
Views & Templating
Template Parser
$this->load->library('parser');
$data = array(
'blog_title' => 'Six Blog',
'blog_heading' => 'A blog about computing',
'blog_entries' => array(
array('title' => 'Title 1', 'body' => 'Body 1'),
array('title' => 'Title 2', 'body' => 'Body 2'),
array('title' => 'Title 3', 'body' => 'Body 3'),
array('title' => 'Title 4', 'body' => 'Body 4'),
array('title' => 'Title 5', 'body' => 'Body 5')
)
); // This could be the result of a query as well!
$this->parser->parse(tpl', $data);
Views & Templating
<html>
<head>
<title>{blog_title}</title>
</head>
<body>
<h3>{blog_heading}</h3>
{blog_entries}
<h5>{title}</h5>
<p>{body}</p>
{/blog_entries}
</body>
</html>
Basic substitution
blog_entries is an array
and this is a render
cycle
Libraries & Helpers
CI provides a bunch of libraries and helpers.
We already saw the Output library (one of
the few libraries that are auto loaded by CI
itself), but there are many more.
Libraries & Helpers
Benchmarking Class
Caching Driver
Calendaring Class
Shopping Cart Class
Config Class
Email Class
Encrypt Class
Encryption Library
File Uploading Class
Form Validation
FTP Class
Image Manipulation Class
Input Class
Javascript Class
Language Class
Loader Class
Migrations Class
Output Class
Pagination Class
Template Parser Class
Security Class
Session Library
HTML Table Class
Trackback Class
Typography Class
Unit Testing Class
URI Class
User Agent Class
XML-RPC and XML-RPC Server Classes
Zip Encoding Class
Libraries & Helpers
Helpers, as the name suggests, help you with tasks. Each
helper file is simply a collection of functions in a particular
category.
There are URL Helpers, that assist in creating links, there are
Form Helpers that help you create form elements, Text
Helpers perform various text formatting routines, Cookie
Helpers set and read cookies, File Helpers help you deal with
files, etc
Libraries & Helpers
Array Helper
CAPTCHA Helper
Cookie Helper
Date Helper
Directory Helper
Download Helper
Email Helper
File Helper
Form Helper
HTML Helper
Inflector Helper
Language Helper
Number Helper
Path Helper
Security Helper
Smiley Helper
String Helper
Text Helper
Typography Helper
URL Helper
XML Helper
Extending CodeIgniter
CI provides many ways to extend the framework
● Custom libraries
● Estensione system libraries
● Hooks
● Sparks plugins ( http://getsparks.org/ )
● Easy integration with Composer
Extending CodeIgniter
You can replace or extend the system libraries provided by CI.
To replace them with your own implementation,simply create a
library with the same name as the one you want to replace in
application/libraries.
To extend them, create a new class prefixed by the default extender
prefix (see application/config/config.php), like this:
class MY_Email extends CI_Email { … }
Extending CodeIgniter
With hooks you can tap into the framework
core and modify its behaviour without
hacking the core files
Extending CodeIgniter
Defining a hook
in application/config/hooks.php each key in $hook represents a script at a certain point of the
application lifecycle:
$hook['pre_controller'] = array(
'class' => 'MyClass',
'function' => 'Myfunction',
'filename' => 'Myclass.php',
'filepath' => 'hooks',
'params' => array('beer', 'wine', 'snacks')
);
Available hook points are: pre_system, pre_controller, post_controller_constructor,
post_controller, display_override, cache_override, post_system.
Q & A

Contenu connexe

Tendances

C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTDr. Awase Khirni Syed
 
IBM API Connect - overview
IBM API Connect - overviewIBM API Connect - overview
IBM API Connect - overviewRamy Bassem
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniterschwebbie
 
Migrating .NET Application to .NET Core
Migrating .NET Application to .NET CoreMigrating .NET Application to .NET Core
Migrating .NET Application to .NET CoreBaris Ceviz
 
Cross Origin Resource Sharing
Cross Origin Resource SharingCross Origin Resource Sharing
Cross Origin Resource SharingLuke Weerasooriya
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for BeginnersJason Davies
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaEdureka!
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEMAccunity Software
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to DjangoJames Casey
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - APIChetan Gadodia
 

Tendances (20)

API Presentation
API PresentationAPI Presentation
API Presentation
 
Angular Seminar-js
Angular Seminar-jsAngular Seminar-js
Angular Seminar-js
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
 
IBM API Connect - overview
IBM API Connect - overviewIBM API Connect - overview
IBM API Connect - overview
 
OAuth
OAuthOAuth
OAuth
 
What is an API?
What is an API?What is an API?
What is an API?
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Migrating .NET Application to .NET Core
Migrating .NET Application to .NET CoreMigrating .NET Application to .NET Core
Migrating .NET Application to .NET Core
 
Api presentation
Api presentationApi presentation
Api presentation
 
Cross Origin Resource Sharing
Cross Origin Resource SharingCross Origin Resource Sharing
Cross Origin Resource Sharing
 
Django for Beginners
Django for BeginnersDjango for Beginners
Django for Beginners
 
Web api
Web apiWeb api
Web api
 
What is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | EdurekaWhat is REST API? REST API Concepts and Examples | Edureka
What is REST API? REST API Concepts and Examples | Edureka
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
 
Angular overview
Angular overviewAngular overview
Angular overview
 
Introduction to Django
Introduction to DjangoIntroduction to Django
Introduction to Django
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Apigee Products Overview
Apigee Products OverviewApigee Products Overview
Apigee Products Overview
 
Introduction to REST - API
Introduction to REST - APIIntroduction to REST - API
Introduction to REST - API
 

En vedette

PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterJamshid Hashimi
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Txesus Zubiate | landscape version portfolio
Txesus Zubiate | landscape version portfolioTxesus Zubiate | landscape version portfolio
Txesus Zubiate | landscape version portfolioTxesus Zubiate
 
Right Turn e Design - BNI 8 Min Presentation
Right Turn e Design - BNI 8 Min Presentation Right Turn e Design - BNI 8 Min Presentation
Right Turn e Design - BNI 8 Min Presentation Right Turn e Design
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniterPiti Suwannakom
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniterAhmad Arif
 
Front End Innovation - Peter Koen
Front End Innovation - Peter KoenFront End Innovation - Peter Koen
Front End Innovation - Peter KoenBrand Genetics
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterPongsakorn U-chupala
 
Continuous Improvement Project
Continuous Improvement ProjectContinuous Improvement Project
Continuous Improvement ProjectDarlene Lebaste
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsTuyen Vuong
 
Introduction to codeigniter
Introduction to codeigniterIntroduction to codeigniter
Introduction to codeigniterHarishankaran K
 
A PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATION
A PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATIONA PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATION
A PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATIONSagar Anand
 

En vedette (20)

PHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniterPHP Frameworks & Introduction to CodeIgniter
PHP Frameworks & Introduction to CodeIgniter
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Txesus Zubiate | landscape version portfolio
Txesus Zubiate | landscape version portfolioTxesus Zubiate | landscape version portfolio
Txesus Zubiate | landscape version portfolio
 
Right Turn e Design - BNI 8 Min Presentation
Right Turn e Design - BNI 8 Min Presentation Right Turn e Design - BNI 8 Min Presentation
Right Turn e Design - BNI 8 Min Presentation
 
Introduction to CodeIgniter
Introduction to CodeIgniterIntroduction to CodeIgniter
Introduction to CodeIgniter
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Front End Innovation - Peter Koen
Front End Innovation - Peter KoenFront End Innovation - Peter Koen
Front End Innovation - Peter Koen
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
CodeIgniter 101 Tutorial
CodeIgniter 101 TutorialCodeIgniter 101 Tutorial
CodeIgniter 101 Tutorial
 
Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniter
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Introduction to MySQL
Introduction to MySQLIntroduction to MySQL
Introduction to MySQL
 
Continuous Improvement Project
Continuous Improvement ProjectContinuous Improvement Project
Continuous Improvement Project
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
 
MySql slides (ppt)
MySql slides (ppt)MySql slides (ppt)
MySql slides (ppt)
 
Introduction to codeigniter
Introduction to codeigniterIntroduction to codeigniter
Introduction to codeigniter
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
A PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATION
A PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATIONA PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATION
A PROJECT REPORT ON EXPORT PROCESS AND DOCUMENTATION
 

Similaire à Code igniter - A brief introduction

Asp.net With mvc handson
Asp.net With mvc handsonAsp.net With mvc handson
Asp.net With mvc handsonPrashant Kumar
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET Journal
 
Overview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company indiaOverview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company indiaJignesh Aakoliya
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009ken.egozi
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep DiveGabriel Walt
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docxfantabulous2024
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101Rich Helton
 
Innovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsInnovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsSteve Speicher
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterKHALID C
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend FrameworkJuan Antonio
 
Codeigniter simple explanation
Codeigniter simple explanation Codeigniter simple explanation
Codeigniter simple explanation Arumugam P
 
Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1Paxcel Technologies
 
Nasdanika Foundation Server
Nasdanika Foundation ServerNasdanika Foundation Server
Nasdanika Foundation ServerPavel Vlasov
 

Similaire à Code igniter - A brief introduction (20)

Asp.net With mvc handson
Asp.net With mvc handsonAsp.net With mvc handson
Asp.net With mvc handson
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
Overview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company indiaOverview of MVC Framework - by software outsourcing company india
Overview of MVC Framework - by software outsourcing company india
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
Company Visitor Management System Report.docx
Company Visitor Management System Report.docxCompany Visitor Management System Report.docx
Company Visitor Management System Report.docx
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
Mvc
MvcMvc
Mvc
 
sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
 
AspMVC4 start101
AspMVC4 start101AspMVC4 start101
AspMVC4 start101
 
Knolx session
Knolx sessionKnolx session
Knolx session
 
Innovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC IntegrationsInnovate2011 Keys to Building OSLC Integrations
Innovate2011 Keys to Building OSLC Integrations
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 
Codeigniter simple explanation
Codeigniter simple explanation Codeigniter simple explanation
Codeigniter simple explanation
 
Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1Html5 deciphered - designing concepts part 1
Html5 deciphered - designing concepts part 1
 
Nasdanika Foundation Server
Nasdanika Foundation ServerNasdanika Foundation Server
Nasdanika Foundation Server
 

Plus de Commit University

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfCommit University
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfCommit University
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Commit University
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit University
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PACommit University
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Commit University
 
Prisma the ORM that node was waiting for
Prisma the ORM that node was waiting forPrisma the ORM that node was waiting for
Prisma the ORM that node was waiting forCommit University
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityCommit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfCommit University
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Commit University
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsCommit University
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftCommit University
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneCommit University
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcCommit University
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeCommit University
 

Plus de Commit University (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
 
Slide-10years.pdf
Slide-10years.pdfSlide-10years.pdf
Slide-10years.pdf
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
 
Vue.js slots.pdf
Vue.js slots.pdfVue.js slots.pdf
Vue.js slots.pdf
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptx
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PA
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
 
Prisma the ORM that node was waiting for
Prisma the ORM that node was waiting forPrisma the ORM that node was waiting for
Prisma the ORM that node was waiting for
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdf
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step Functions
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and Swift
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazione
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lc
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-Code
 
SwiftUI vs UIKit
SwiftUI vs UIKitSwiftUI vs UIKit
SwiftUI vs UIKit
 

Dernier

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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Dernier (20)

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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

Code igniter - A brief introduction

  • 2. What is it? CI is a HMVC framework for rapid PHP web application development. It’s focused on performance, ease of use and minimal configuration. MVC pattern is encouraged but not enforced.
  • 3. What is it? It has been mantained by EllisLab until 2014 ( http: //ellislab.com/ ) . Since then the code is mantained by British Columbia Institute of Technology ( http://bcit.ca/ ) Find the contributors list on the GitHub project page: https://github.com/bcit- ci/CodeIgniter/graphs/contributors
  • 4. Why using it ● Flexible and easy to extend ● Lightweight and performant ● Noob friendly ● Minimal configuration ● It can use templating engines, but doesn’t need one ● VERY well documented ● CI Sparks / Composer ● Active community
  • 5. Main features ● HMVC architecture ● Query-builder database support ● Drivers for main DBMS systems (MySQL, MS SQL Server, Postgres, Oracle etc...) ● CSRF and XSS Filtering ● Session management ● Benchmarking
  • 6. Main features ● Image manipulation (requires GD, ImageMagick or NetPBM) ● Email library ● Uploading ● Caching ● CLI interface ● Internationalization ● … too many to be listed here.
  • 7. Architectural goals ● Dynamic instantiation: libraries and helpers are loaded by controllers on demand when they are needed, keeping the system light and reactive ● Components singularity: each class and its functions are highly autonomous in order to allow maximum usefulness ● Loose coupling: each component minimizes its reliance on other components, becoming more reusable.
  • 8. Requirements ● PHP 5.2.4 (5.4 is recommended) ● A Web Server Remind that, as of PHP 5.4, the interpreter provides a built-in web server to test your applications. So you do not really need a stand alone web server to start developing.
  • 9. application/config/config.php holds most of the configuration you need to start developing your application, such as base_url (e.g. http://google. com/, if Google was written with CI), URLs suffixes, default charsets, locales, hooks configuration, Composer integration and much more. Basic configuration
  • 10. Routing & Controllers Preliminar note: CI provides a index.php script which triggers the framework lifecycle for each request. To remove index.php from URL and to route every request to it, you can use mod_rewrite on Apache like this https://gist.github. com/sixpounder/c61e660b43c0aa2b9356 For PHP builtin server look at this GIST https://gist.github. com/sixpounder/6758cddd83330125bc10 From now on we assume index.php to be removed from URLs.
  • 11. Routing & Controllers A request lifecycle in CI
  • 12. Routing & Controllers CI URLs are basically query string arguments to index.php. They are made of URI segments that represent (by default, but this can be changed in application/config/config.php by defining custom routes) the controller and the method responsible for serving a request mapped on that specific URL.
  • 13. Routing & Controllers example.com/news/article/ID ● The first segment represents the controller class to be invoked ● The second segment represents the controller instance method that will be executed (assuming index if not specified) ● The third (and any further) segment represents an additional parameter that will be passed to the controller method as an argument.
  • 14. Routing & Controllers ● These URLs are SEO-friendly! ● You can organize controllers in sub folders. In this case, the initial URI segments will represent your folder structure. ● Classic query strings are available ● You can add URLs suffixes ● You can define overrides, custom URI routings and the default controller in application/config/routes.php
  • 15. Routing & Controllers Controller classes extend CI_Controller and must be placed in application/controllers. Class name must have its first letter capitalized and it must match the file name. /* application/controllers/Article.php */ class Article extends CI_Controller { … }
  • 16. Models are classes that interacts with your database. CI doesn’t provide an ORM like Rails Active Record, rather it provides a Query Builder that builds queries by masking the underlying physical DBMS implementation. Models
  • 17. Models ● Models should be indepent from the components that use them ● Query Builder supports transactions ● Database Forge Class can be used to manage the physical structure of your database (so you do not have the responsability to do so!) ● Support for migrations (by extending CI_Migration)
  • 18. Models To load and use a model inside a controller: $this->load->model(‘model_name’); Models must be placed in application/models. Classes and file names must have their first letter capitalized and the rest of the name lowercase. They must extend CI_Model.
  • 19. Views & Templating CI’s core provides different ways of sending an output to a client, like basic view rendering, simple template parsing and direct output control. All these methods are wrapped into core libraries.
  • 20. Views & Templating View rendering A view is simply a web page, or a page fragment, like a header, footer, sidebar, etc. In fact, views can flexibly be embedded within other views (within other views, etc., etc.) if you need this type of hierarchy. Views are stored by default in application/views directory and have .php extension (unless you need something different, eg. if you are using twig). A controller can render a view by loading it like this: $this->load->view(‘viewname’);
  • 21. Views & Templating View rendering Data is passed from the controller to the view by way of an array or an object in the second parameter of the view loading method. $data = array('title' => 'My Title','heading' => 'My Heading','message' => 'My Message'); $this->load->view('blogview', $data);
  • 22. Views & Templating View rendering A third boolean argument may be provided to the view loader. If it is present and its value is TRUE the method returns the string representation of the finalized view. This can be usefull for templating purposes. $data = array('title' => 'My Title','heading' => 'My Heading','body' => 'Article body'); var $content = $this->load->view('article', $data, TRUE);
  • 23. Views & Templating Output Library The Output Library is used under-the-hood by the view loader to finalize the output before sending it to the client. It can be directly used, for instance, to send a JSON output if you are dealing with a REST API, or a file’s content if you are writing a file server and so on.
  • 24. Views & Templating JSON example $this->output->set_content_type('application/json')->set_output(json_encode(array ('foo' => 'bar'))); Sending an image $this->output->set_content_type('jpeg')->set_output(file_get_contents ('files/something.jpg')); HINT: The _display() method is called automatically at the end of script execution, you won’t need to call it manually unless you are aborting script execution using exit() or die() in your code. Calling it without aborting script execution will result in duplicate output.
  • 25. Views & Templating Template Parser The Template Parser Library can parse simple templates by operating basic substitutions of pseudo-variables contained in your views. Pseudo variables must be enclosed in braces.
  • 26. Views & Templating Template Parser $this->load->library('parser'); $data = array( 'blog_title' => 'Six Blog', 'blog_heading' => 'A blog about computing', 'blog_entries' => array( array('title' => 'Title 1', 'body' => 'Body 1'), array('title' => 'Title 2', 'body' => 'Body 2'), array('title' => 'Title 3', 'body' => 'Body 3'), array('title' => 'Title 4', 'body' => 'Body 4'), array('title' => 'Title 5', 'body' => 'Body 5') ) ); // This could be the result of a query as well! $this->parser->parse(tpl', $data);
  • 28. Libraries & Helpers CI provides a bunch of libraries and helpers. We already saw the Output library (one of the few libraries that are auto loaded by CI itself), but there are many more.
  • 29. Libraries & Helpers Benchmarking Class Caching Driver Calendaring Class Shopping Cart Class Config Class Email Class Encrypt Class Encryption Library File Uploading Class Form Validation FTP Class Image Manipulation Class Input Class Javascript Class Language Class Loader Class Migrations Class Output Class Pagination Class Template Parser Class Security Class Session Library HTML Table Class Trackback Class Typography Class Unit Testing Class URI Class User Agent Class XML-RPC and XML-RPC Server Classes Zip Encoding Class
  • 30. Libraries & Helpers Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category. There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc
  • 31. Libraries & Helpers Array Helper CAPTCHA Helper Cookie Helper Date Helper Directory Helper Download Helper Email Helper File Helper Form Helper HTML Helper Inflector Helper Language Helper Number Helper Path Helper Security Helper Smiley Helper String Helper Text Helper Typography Helper URL Helper XML Helper
  • 32. Extending CodeIgniter CI provides many ways to extend the framework ● Custom libraries ● Estensione system libraries ● Hooks ● Sparks plugins ( http://getsparks.org/ ) ● Easy integration with Composer
  • 33. Extending CodeIgniter You can replace or extend the system libraries provided by CI. To replace them with your own implementation,simply create a library with the same name as the one you want to replace in application/libraries. To extend them, create a new class prefixed by the default extender prefix (see application/config/config.php), like this: class MY_Email extends CI_Email { … }
  • 34. Extending CodeIgniter With hooks you can tap into the framework core and modify its behaviour without hacking the core files
  • 35. Extending CodeIgniter Defining a hook in application/config/hooks.php each key in $hook represents a script at a certain point of the application lifecycle: $hook['pre_controller'] = array( 'class' => 'MyClass', 'function' => 'Myfunction', 'filename' => 'Myclass.php', 'filepath' => 'hooks', 'params' => array('beer', 'wine', 'snacks') ); Available hook points are: pre_system, pre_controller, post_controller_constructor, post_controller, display_override, cache_override, post_system.
  • 36. Q & A