Skip to content

CodeIgniter is a lightweight PHP framework that follows the Model-View-Controller (MVC) architectural pattern. MVC is a software design pattern that separates an application into three interconnected components: 1 - Model 2 - View 3- Controller

Notifications You must be signed in to change notification settings

ramin123/CodeIgniter-MVC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CodeIgniter MVC Application

This repository contains a simple application built using the CodeIgniter framework, which follows the Model-View-Controller (MVC) design pattern.

Table of Contents

Getting Started

To get the application up and running, follow these steps:

  1. Clone the repository:
git clone https://github.com/ramin123/systemMVC.git
  1. Navigate to the project directory:
cd your-repository
  1. Set up the database and configure the application/config/database.php file.
  2. Run the application on your local server.

File Structure

The project is structured as follows:

your-repository/
|-- application/
|   |-- config/
|   |-- controllers/
|   |-- models/
|   |-- views/
|   |-- ...
|-- system/
|-- public/
|   |-- css/
|   |-- js/
|   |-- index.php
|-- .htaccess
|-- README.md

Models

Models contain the logic for interacting with the database. Here's an example model:

class ProductModel extends CI_Model {
    public function get_products() {
        // Code to retrieve products from the database
        $query = $this->db->get('products');
        return $query->result();
    }
}

Views

Views are responsible for displaying the data to the user. Here's an example view:

<!-- View file: application/views/products_view.php -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Products List</title>
</head>
<body>
    <h1>Products</h1>
    <ul>
        <?php foreach ($products as $product) : ?>
            <li><?php echo $product->name; ?> - <?php echo $product->price; ?></li>
        <?php endforeach; ?>
    </ul>
</body>
</html>

Controllers

Controllers act as an intermediary between models and views. Here's an example controller:

class Products extends CI_Controller {
    public function index() {
        $this->load->model('ProductModel');
        $data['products'] = $this->ProductModel->get_products();
        $this->load->view('products_view', $data);
    }
}

Usage

To access the application, navigate to the URL corresponding to the controller's class and method, such as http://localhost/index.php/products.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


About

CodeIgniter is a lightweight PHP framework that follows the Model-View-Controller (MVC) architectural pattern. MVC is a software design pattern that separates an application into three interconnected components: 1 - Model 2 - View 3- Controller

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published