Sie sind auf Seite 1von 7

Course Code IT342

Description Web Application Development 2

College / Department:
LabExer No. 1
Online Education

LABORATORY EXERCISE AND MACHINE PROBLEM Page 1 of 7

Introduction

Instruction: Create a program to display the following using Codeigniter.

Hello World

This is my first CodeIgniter application

Step 1. Install CodeIgniter Framework on your root directory or your project folder.
Example:
If you are using WAMP Server
Root Directory: C:\wamp\www
Project Folder Directory: C:\wamp\www\project_folder
If you are using XAMPP Server
Root Directory: C:\xampp\htdocs
Project Folder Directory: C:\xampp\htdocs\project_folder
Step 2. Test if you’ve set it up correctly
Open your Browser and type in localhost/project_folder on the address bar.

If a Welcome to CodeIgniter message appears, it’s running correctly.

1
Course Code IT342

Description Web Application Development 2

College / Department:
LabExer No. 1
Online Education

LABORATORY EXERCISE AND MACHINE PROBLEM Page 2 of 7

If not, make sure your server is online and running correctly. Check your apache configurations.

Step 3. Open your Text Editor.

Using a code editor, type the following codes and name it as Home.php.

Create a file at application/controllers/Home.php with this code:

You just created a Controller named Home.


2
Course Code IT342

Description Web Application Development 2

College / Department:
LabExer No. 1
Online Education

LABORATORY EXERCISE AND MACHINE PROBLEM Page 3 of 7

When creating CodeIgniter controllers, you must extend the CI_Controller. It extends the

CI_Controller class methods that you can use on your newly created controller.

The index function or method (it is called method because it is on the class) will be called if

the Home controller was requested on the browser when there is no method specified.

Step 4. Go to your http://localhost/index.php/Home to request the Home/index method.

You should see the page with “Hello World” printed.

Step 5. Add another method.


Add the following code under the index method code block:

This will print “This is my first CodeIgniter application” in the browser.


The about method can be called by http://localhost/index.php/Home/about

3
Course Code IT342

Description Web Application Development 2

College / Department:
LabExer No. 1
Online Education

LABORATORY EXERCISE AND MACHINE PROBLEM Page 4 of 7

You might be wondering why the index method loads when it is called by
http://localhost/index.php/Home
And that is should be
http://localhost/index.php/Home/index
The Answer is: Well it works both ways.

Machine Problem
Create a program using CodeIgniter that will display the corresponding text when a method is called.

1. Method: Products

Text: “Our Special Pasta Menu”

2. Method: About Us

Text: “About the Pasta House”

3. Method: Contact Us

Text: “For comment and suggestions, please contact…”

4. Method: FAQ

Text: “Frequently asked Questions”

====================================

4
Course Code IT342

Description Web Application Development 2

College / Department:
LabExer No. 1
Online Education

LABORATORY EXERCISE AND MACHINE PROBLEM Page 5 of 7

=================================
Welcome screen:

==============================
Below are the results. I used port 8080 for the apache, cause I having trouble using port 80.
http://localhost:8080/index.php/Home

5
Course Code IT342

Description Web Application Development 2

College / Department:
LabExer No. 1
Online Education

LABORATORY EXERCISE AND MACHINE PROBLEM Page 6 of 7

====================

http://localhost:8080/index.php/Home/about

==============

6
Course Code IT342

Description Web Application Development 2

College / Department:
LabExer No. 1
Online Education

LABORATORY EXERCISE AND MACHINE PROBLEM Page 7 of 7

Das könnte Ihnen auch gefallen