The document discusses the CodeIgniter PHP web application framework. It provides an overview of CodeIgniter, describing it as a lightweight and open source model-view-controller framework that is easy to configure and supports multiple databases. Key CodeIgniter features include its built-in classes for common tasks like database access, input handling, loading resources, and validation.
4. CodeIgniter
CodeIgniter is a lightweight web application framework written in PHP that adopts
the model-view-controller approach to development
Download link: https://codeigniter.com/download
UserGuide link: https://codeigniter.com/userguide2/
5. Why use a framework?
Web application frameworks provide basic building blocks needed by applications
– Database connections
– Business logic
– Form handling
– Separation of concerns
– Easier testing (unit tests)
6. Why use CodeIgniter?
– Feature rich
– Lightweight
– Open source
– Well-supported by an active community
– Excellent “by example” documentation
– Easy to configure
– Supports multiple databases
7. Model-View-Controller
Model – representation of the data Model
View – rendering of the data suitable for interaction with the user.
Controller – the “traffic cop” that passes model data to the views and vice versa.
This separation of concerns allows for greater flexibility, reuse of code, and
overall preservation of the developer’s sanity
8. Controller
A class containing one or more related methods (custom PHP functions)
Typical uses: – Request a set of data from the model by sending arguments
– Send a payload of data to a view (web page)
– Receive a data payload from a view
– Apply business logic to make decisions
– Pass data to the model for inclusion in a database
9. View
Code that displays information to the user
Views can be:
– Web pages with PHP code snippets inserted
– Web pages with forms to gather user input
– Other output (CSV, PDF, etc.)
10. Model
A class containing one or more related (custom PHP functions) methods,
Typical uses: – Create
– Read
– Update
– Delete
11. CodeIgniter Classes
CI’s built-in classes contain the basic functionality that are frequently used by web
applications
The most-used classes are:
– Database
– Input
– Loader
– URI
– Validation
12. Database Class
– Generates queries using the Active Record Pattern
– Automatic escaping of input values
– Provides method “chaining” for easy query building
– $this->load->database(); // database class load here.
– $this->db->get(‘usermaster’); // Fetch data from usermaster table.
13. Input Class
Provides access to user input and other data:
– Form fields (POST)
– Cookies
– Server variables
– $this->input->post(‘fieldname’);
14. Loader Class
Makes various resources available:
– Databases
– Views
– Helpers
– Plugins
$this->load->view(‘viewname’);
15. URI Class
Provides access to specific parts of the URI string
Useful for building RESTful URIs
$this->uri->segment(n);
16. Validation Class
Helps validate user form input
– Required fields
– Required string formatting (length, regexp)
– Enables success and failure messages on form submittal
17. Other Classes
Benchmarking Calendaring
Email Encryption
File uploading FTP
HTML Table Image Manipulation
Language (internationalization) Output
Pagination Session
Trackback Unit testing
XML-RPC Zip encoding