CodeIgniter uses MVC architecture.
Model
Stores php files which are communicate with the database. Get, store, update informations to the database are handled by php files in model. Login, registration, etc...
View
Stores php files which display informations in the browser. Tables, images, descriptions, etc..
Controller
Stores php files which make the connection between model and the view. When files in the model get information, the controller will call the relevant file in the view and display them to the user.
Let's start coding with CodeIgniter framework.
Step
1 : Download codeIgniter framework from CodeIgniter.
Step
2 : Copy files to a folder called Login (in my case the folder path
/home/shyamali/Projects/CodeIgniter/Login)
Step
3 : Then open Login folder by using PhpStorm. If you have not yet
installed PhpStrom How
to install PhpStrom in Ubuntu 16.04.
Step 5 : Then you can create a virtual host to run your codeIgniter
project by using Create an apache virtual host in ubuntu 16.04. Now you are ready to code php.
Step 6 : To style your project you can add Bootstrap to you project Merge Bootstrap to your current codeIgniter project in PhpStorm on ubuntu 16.04.
Let's create a simple example in your project.
Create a controller name Test.php in your controller. Right click on controllers -> New -> Php Class.
defined('BASEPATH') OR exit('No direct script access allowed');Then extends it to CI_Controller class.
class Test extends CI_Controller { //your code }You have to create a view file in views called welcome.php. Inside the view file you can add content that you want to display in the browser. For the moment I have just echo welcome message.
echo "Welcome";Then create a function called welcome_view() inside the Test class. Then you have to load the created view inside the function.
$this->load->view("welcome");Now you have created view file and the controller. Then you have to navigate your browser type url with your view. The view file has been loaded by the controller. Now you just have to make the connection with your url and the welcome_view() function. To do that you have to give routes. There is a file called routes.php inside config directory. Open it and at the end paste following code.
$route['welcome'] ='Test/welcome_view';This means when you type your base url/welcome goto Test class welcome_view function.
Test.php
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Test extends CI_Controller { public function welcome_view() { $this->load->view("welcome"); } }welcome.php
<?php echo "Welcome";Inside the routes.php file
$route['welcome'] ='Test/welcome_view';
Like us on facebook
Hi Shyamali, this must be the worst place to ask this question but i was reading a question posted by you on stack overflow 6 months ago the link is:
ReplyDeletehttps://stackoverflow.com/questions/46406645/ide-fatal-errors-getlayoutlibrary-returned-null
i just wanted to ask if you have resolved the issue if yes how you can contact me at yogeshdhmn@gmail.com, I know you'll be feeling weird but I am a beginner had no other option, thanks in advance......
This comment has been removed by the author.
ReplyDeleteI like to use Codelobster IDE for CodeIgniter projects
ReplyDelete