DEV Community

Cover image for CodeIgniter
jrob112
jrob112

Posted on • Updated on

CodeIgniter

Code Igniter is an opensource PhP framework that was built in 2006, by Ellis Labs, on the Model-View-Controller (MVC) development pattern.

When compared to other PhP frameworks, CodeIgniter is known for its speed. It allows the possibility to write code more quickly with it's vast libraries and use of helpers than from scratch. Not only is it speedy to develop, but it also has faster loading times when contrasted against most PHP frameworks. In August of 2008, Rasmus Lerdorf said that he liked CodeIgniter "because it is faster, lighter and the least like a framework."

FEATURES

  1. Model-View-Controller Architecture:
    The use of MVC that separates logic and presentation components allows developers to build dynamic websites more efficiently. While controller classes are a necessary part of development under CodeIgniter, models and views are optional

  2. Form and Data Validation:
    There are easy to use methods to validate form data. When using a form helper to create a form you could use standard HTML. Although, the benefit of using the helper is that it generates the action URL based on the URL in your config file. This allows your application to have improved portability in the event your URLs change

  3. Error Handling:
    There are 3 message types-
    *Error Messages: The $message(mixed) function returns an error message.
    *Debugging Messages: The $status_code(int) function returns a HTTP Response status code.
    *Informational Messages: The $heading(string) function returns the error page heading.

  4. Security:
    There are built in protections for CSRF and XSS attacks. The xss-clean() method looks for commonly used techniques to trigger JavaScript or other types of code that attempt to hijack cookies or do other malicious things

  5. Configuration:
    It has a straightforward approach to install with minimal configuration. In just four simple steps CodeIgniter is installed.
    *1) Unzip the package downloaded from the PhP website.
    *2) Upload the files and folders to your server.
    *3) Open the application/config/config.php file with a text editor and set your base URL. Set your encryption key if you plan on using an encryption or sessions.
    *4) Open the application/config/database.php file with a text editor and set your database settings.

Once you download CodeIgniter from its official website you can configure it to work with your local development environment. For extra security you can hide the location of the CodeIgniter files by renaming the system and application folders. If you do, in the main index.php file be sure to reset the values to the $system_folder and $application_folder variables to the names that you chose. Next, move the two folders above the web root so that they are not directly accessible via a browser.

Examples:
Query binding with named placeholders

$sql = "SELECT * FROM users WHERE username = :username AND password = :password";
$this->db->query($sql, array('username' => $username, 'password' => $password));
Enter fullscreen mode Exit fullscreen mode

Escaping user input

$username = $this->db->escape($username); $password =
$this->db->escape($password); $sql = "SELECT * FROM users WHERE username =
$username AND password = $password"; $this->db->query($sql);
Enter fullscreen mode Exit fullscreen mode

Any PhP developer should consider the use of CodeIgniter for their web application development because of its speed, simplicity and security features.

REFERNCES:
1)https://codeigniter.com/userguide2/general/errors.html
2)https://www.webomindapps.com/codeigniter-security-best-practices.html
3)https://en.wikipedia.org/wiki/CodeIgniter#:~:text=License%20Awareness%20Week.-,History,EllisLab%20on%20February%2028%2C%202006.

Top comments (0)