background preloader

CodeIgniter, le framework au service des Zéros

CodeIgniter, le framework au service des Zéros

Wikipédia : CodeIgniter Un article de Wikipédia, l'encyclopédie libre. CodeIgniter est un framework libre écrit en PHP. Il suit le motif de conception MVC et s'inspire du fonctionnement de Ruby on Rails. Les versions inférieures à la 2.0.0 sont compatibles avec PHP 4 et 5, tandis que celles supérieures à la 2.0.0 ne sont compatibles qu'avec PHP 5.1.6 ou plus. La version 3.0 en cours de développement requiert PHP 5.2.4. §Histoire[modifier | modifier le code] CodeIgniter est issue de la société EllisLab [1] et a été conçu par Rick Ellis[2], PDG de cette entreprise située dans l'Oregon, aux États-Unis. La première version de CodeIgniter a été publiée le 28 février 2006. Depuis juillet 2013, EllisLab recherchait un nouveau repreneur pour CodeIgniter[4]. §Fonctionnalités[modifier | modifier le code] La documentation de CodeIgniter est complète. CodeIgniter encourage fortement l'utilisation de l'architecture Modèle-Vue-Contrôleur. Classes et bibliothèques simplifiant le codage : Sécurité du site :

Config Class The Config class provides a means to retrieve configuration preferences. These preferences can come from the default config file (application/config/config.php) or from your own custom config files. Note: This class is initialized automatically by the system so there is no need to do it manually. Anatomy of a Config File By default, CodeIgniter has one primary config file, located at application/config/config.php. You can add your own config items to this file, or if you prefer to keep your configuration items separate (assuming you even need config items), simply create your own file and save it in config folder. Note: If you do create your own config files use the same format as the primary one, storing your items in an array called . Loading a Config File Note: CodeIgniter automatically loads the primary config file (application/config/config.php), so you will only need to load a config file if you have created your own. There are two ways to load a config file: Fetching Config Items

Session Class The Session class permits you maintain a user's "state" and track their activity while they browse your site. The Session class stores session information for each user as serialized (and optionally encrypted) data in a cookie. It can also store the session data in a database table for added security, as this permits the session ID in the user's cookie to be matched against the stored session ID. By default only the cookie is saved. If you choose to use the database option you'll need to create the session table as indicated below. Note: The Session class does not utilize native PHP sessions. Note: Even if you are not using encrypted sessions, you must set an encryption key in your config file which is used to aid in preventing session data manipulation. Initializing a Session Sessions will typically run globally with each page load, so the session class must either be initialized in your controller constructors, or it can be auto-loaded by the system. $this->load->library function:

Form Validation CodeIgniter provides a comprehensive form validation and data prepping class that helps minimize the amount of code you'll write. Before explaining CodeIgniter's approach to data validation, let's describe the ideal scenario: A form is displayed.You fill it in and submit it.If you submitted something invalid, or perhaps missed a required item, the form is redisplayed containing your data along with an error message describing the problem.This process continues until you have submitted a valid form. On the receiving end, the script must: Check for required data.Verify that the data is of the correct type, and meets the correct criteria. Although there is nothing terribly complex about the above process, it usually requires a significant amount of code, and to display error messages, various control structures are usually placed within the form HTML. What follows is a "hands on" tutorial for implementing CodeIgniters Form Validation. The Form Using a text editor, create a form called myform.php

CodeIgniter A Brief History 2006: CodeIgniter was born. CodeIgniter is a powerful open-source PHP framework with a very small footprint, created by Rick Ellis in 2006. CodeIgniter was born from ExpressionEngine, essentially a collection of refactored classes originally written for EllisLab's flagship CMS. Stripped of the application-specific functionality, CodeIgniter was made to be a simple and elegant toolkit, enabling rapid development of both web sites and web applications, attracting thousands of talented PHP developers. 2008: Industry leader. 2009: ExpressionEngine 2.0. Where is CodeIgniter Now? 2014: BCIT Stewardship.