In this tutorial, the author will provide a tutorial on the basic use of the php framework is CodeIgniter. The author uses CodeIgniter v 2.1.4 which can be downloaded directly from the official web CodeIgniter, ie http://ellislab.com/codeigniter. What is needed for this tutorial is:
1. CodeIgniter 2.1.4
2. Text Editor (Sublime Text, CodeIgniter, Brackets, ell)
3. XAMPP / WAMP
CodeIgniter PHP Framework
What is done for the first time is download CodeIgniter v 2.1.4 which has been provided at the official website then extract the download and generate CodeIgniter folder. The folder should be the reader move into the htdocs folder in the XAMPP / WAMP directory.
After that the reader must run the web server contained in XAMPP / WAMP in order to run the PHP script. If it is, the reader can directly open the browser page and then write "localhost / CodeIgniter" in the URL Browser (Without quotes ""), if the display "Welcome to CodeIgniter" means you have successfully used the CodeIgniter framework for the first time
Welcome Page CodeIgniter
Before we discuss how the page can appear, the reader should know that this CodeIgniter framework has a MVC / Model View Controller structure so that when you look at the contents of the application folder inside the CodeIgniter you have downloaded there will be the models, views and controllers folder. (For those who do not understand the MVC programming model, please read here: http://en.wikipedia.org/wiki/Model-view-controller)
Folder Structure on CodeIgniter
Let's look at the routes.php file in the application / config folder, inside the folder there is a code like this:
[Php] $ route ['default_controller'] = "welcome"; [/ php]
-> This code indicates that the default controller or controller that was first executed when running our web application is a welcome.php file that is in the controllers folder.Readers can change the default controller in accordance with the wishes later, patiently yes, hehehe
From there we already know when the website first run (When we type localhost / CodeIgniter) will run the file welcome.php in the application / controllers folder. Inside the welcome.php file contains:
It is the main structure for a controller inside CodeIgniter. The name of the class that is used is Welcome, it is because adjusted with the controller file name is welcome.php. If we have a controller with filename products.php then we have to create a class like this in it:
In the welcome.php file also has a function index, the function is the default function that will be called or run when the first time the controller is running. We can also add another function in it, like this for example:
Later function greetings will call view "say_greetings.php" which later we make :)
After finishing the controller, it's time we switch to Views in the application / views folder. Inside the folder there is the file "welcome_message.php". Well, the file "welcome_message.php" is what was called by the controller welcome.php with code:
So already know the origin of the page "Welcome to CodeIgniter" earlier?
Let's create a new file named say_greetings.php in the views folder to be called by the controller welcome with function greetings.
Once done, let's try to open a new page we created by typing "localhost / CodeIgniter / index.php / welcome / greetings" in our browser URL.
1. CodeIgniter: Is our main folder
2. welcome: The name of our Controller, located in CodeIgniter / application / controllers / welcome.php
3. greetings: Function Name that is inside the controller, ie function greetings
And finally we can add new function to our controller and also show new view that we have created ...
New Screen Shot View we have created :)
If you want to try it yourself please download the script from Github TutWeb
Thus the tutorial from the author for the basic use of the PHP CodeIgniter framework, for the use of the model will be the author discussed in the next tutorial ..