Module 1 Introduction Learning Objectives At the end of the module the student is expected to: • Understand what is codeigniter / CI. • List the reasons why developers use CI. • Enumerate the skills needed in using CI. • Understand the steps in installing CI. • Understand the MVC web framework and its structure in CI. Introduction • Learning and Development in PHP is simple. CodeIgniter – “a powerful PHP framework with a very small footprint, built for developers who need a simple and elegant toolkit to create full-featured web applications.” It sounds very complex but it’s pretty straightforward. • CodeIgniter is developed by Ellislab and used by millions worldwide. Developers prefer to use CI for its rapid application development. It has rich and reusable libraries and class for your website’s foundation. Why use Codeigniter or CI. • • • • • • • • • CI is an application framework CI is free CI is light weight CI is fast CI uses Model-View-Controller architecture CI generates Clean URLs CI is Extensible CI is thoroughly documented CI has a friendly community of users Skills needed • The following are the items you need to know before starting to play around CI. • PHP – A good understanding of the PHP language is a must. As long as you can perform simple instructions (e.g. variable declaration/assignments, conditions, loops), you will nearly understand everything here since the CodeIgniter is made up of PHP! • HTML – Well, you do need those html elements to manipulate to. You’ll use this for the layout design, inputs and presentation of data. Skills needed • CSS – It’s good if you know Cascading Style Sheets (CSS), and even better if you’re using external style sheets. There are more web design processors available if you want to level-up your knowledge on styling however if you don’t know how, still, you can learn CI. • MySQL – This means your SQL Basic queries are required. There will some modules on this book where you need to manipulate I/O (inputs and outputs) from your data storage or your database. Models communicate with the database and uses your fundamental knowledge on SQL. • JavaScript – It makes the website interact with the HTML elements. If you do not know JS, maybe learn it sometime, okay? You need these for future developments. CI Installation • Step 1. Visit its website on https://www.codeigniter.com/ CI Installation • Step 2. Find your way to the Download link and click Download. CI Installation • Step 3. Extract the downloaded .zip file and place it on your local server. CI Installation • Step 4. If you can see this Welcome Message. Your installation was a success! MVC Web Framework MVC MVC • Controller – This contains the Business logic (Business Logic Layer). The controller controls the Model and View. A controller is a class that contains methods that decides what to call, or perform and display. • When a user sends a request on a browser, the controller will determine the process and perform tasks based on its method; it includes calling a method returning a value from a model, displaying and passing values on a view or showing a 404 error page. MVC • Views – The Presentation layer. This contains designs, layouts or templates. It is the collection of what will show up on your browser. The view is where the user sees and interacts with. • Models – It is also referred as the Data Access Layer. The Model communicates with your database. It comprises of methods that execute queries using the CodeIgniter’s Active Record pattern. CI Directory • Basically, CodeIgniter has 3 main folders: Application, System and User Guide. • You will work with your website in Application Folder. • The System folder, keep it a habit to avoid making changes to any of the files inside. It contains the CodeIgniter’s core files which is necessary to make it run. • User_Guide contains the offline documentations you need in developing with websites in CI. CI Directory CI Directory • Cache: This directory will contain all kinds of cached files if you are using so. However, you will may need to provide write access for the application to this directory as codeigniter will need to create temporary files on this folder. To know how to use caching, please refer to CodeIgniter caching tutorial. • Config: This directory includes settings/configuration related information like database settings, route information, constants declaration, items to be auto loaded etc. • Controller: This directory includes all controller definitions. It can be said as the entry point of application also, every requests triggers a certain method of a controller. CI Directory • Core : If we need to extend the functionality of any core classes like controller, loader, router etc, then we can declare new class here which will extend those core classes and put the implementation inside those. • Errors: This directory includes some basic template for showing various kind of errors like db error, php errors, 404 errors etc, which we can change later as per our requirements. • Helpers: This directory will include all helper files. • Hooks: This directory will include all hooks declaration. • Language: This directory will include language files. By loading different language files, we can make our application multilingual supported CI Directory • Libraries: This directory will include all library class files that might need to be created for our applications. • Logs: This directory will include all application logs. TO know how to write log for debug/error/info, please more about error handling • Migrations: This directory will include migration helpers. • Models: This directory will include all model classes used in our application. This section can be said as the ‘data access layer’ of our application. • Third_party : This directory will include library files, but only those, which are imported from third-party. So, difference between the ‘third_party’ and ‘libraries’ is that, one is for self-made libraries, for app specific, other one is for importing party libraries. • Views : This directory will include all view template files. Thank you…