Showing posts with label ci installation. Show all posts
Showing posts with label ci installation. Show all posts

Saturday, January 27, 2018

Views in codeigniter ... MVC Pattern

As we know, codeigniter works on the MVC pattern, which is Models, Views and Controllers.
We have discussed in detail about the controllers in previous post. Now we are going to discuss about the Views.

First of all we should know that 

What are views in codeigniter ?

Views are considered to be the special files in Codeigniter that are used to store the markup outputted by the applications. Views are consist of HTML and PHP tags. As we all know that HTML is used in front-end designing of websites or any web application. We also know that some of the PHP tags are also used in designing the interfaces of any web application.

A view can be defined as a simple web page, or a page fragment, or any interface of web application with which the end-user is going to interact like header, footer, sidebar or body etc.

How views are created ?

Views can be created by creating a new file  in the views folder which resides in the application folder of codeigniter and saving the file with the .php extension. let say, you have created a file in views folder and saved it with name myView.php. Your View will be created.

The code in the myView.php file is as follow:

<html>
</body>
<h1> This is my View </h1>
<p> I am going to be loaded in the controller that we have created in the previous post </p>
</body>
</html>

How to load Views in Controllers?

The views that we create in the views folder are loaded in controller in order to be displayed on the web. The syntax for loading a view in the controller is as follow:

$this->load->view('myView');

There is no need of giving extention of the file that is .php because codeigniter is an intelligent framework.

Full Code in controller for loading the view:

<?php class MyController extends CI_Controller {
// its the controller that we created in the previous post

public function index(){       // it is the by default function that is called by controller itself
$this->load->view('myView');     // its the view that we have created above
}
}
?>

I hope this would be a help for you. God bless you all. share this post and comment your queries, if any . Thankyou very much

Friday, January 26, 2018

Codeigniter downloading and installation

Codeigniter Downloading Instruction:

you can download the complete package of codeigniter simply by following the link given below:

https://www.codeigniter.com/

Recently the latest version of codeigniter has been launched that is Codeigniter 3.1.7. You can also get the documentation of codeigniter from the above mentioned link which is a plus point of codeigniter that it has clear and well organized documentation. You can download codeigniter simply by clicking the download button.

Codeigniter Installation Instructions:

CodeIgniter is installed in four steps:

  • Unzip the package.
  • Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.
  • Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.
  • If you intend to use a database, open the application/config/database.php file with a text editor and set your database settings.
These are the simple steps to install the codeigniter. If your developing on a local server then move the codeigniter folder to your local server htdocs folder.

In the event that you wish to build security by concealing the area of your CodeIgniter documents you can rename the framework and application organizers to something more private. In the event that you do rename them, you should open your principle index.php record and set the $system_path and $application_folder factors at the highest point of the document with the new name you've picked. 

For the best security, both the system}and}any application envelopes ought to be put above web root with the goal that they are not straightforwardly available by means of a program. Of course, .htaccess documents are incorporated into every envelope to help avoid coordinate access, however it is best to expel them from community on the off chance that the web server design changes or doesn't keep the .htaccess. 

On the off chance that you might want to keep your perspectives open it is additionally conceivable to move the perspectives envelope out of your application organizer.
After moving them, open your main index.php file and set the $system_path, $application_folder and $view_folder variables, preferably with a full path, e.g. ‘/www/MyUser/system’.