0% found this document useful (0 votes)
22 views4 pages

CodeIgniter 3 & 4 Study Guide for Developers

check this

Uploaded by

vvivekmishra0808
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

CodeIgniter 3 & 4 Study Guide for Developers

check this

Uploaded by

vvivekmishra0808
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CodeIgniter 3 & 4 Study Material (For 2

Years Experience)
CodeIgniter 3 - Introduction
- Lightweight PHP framework.
- Uses MVC architecture.
- Faster execution, less dependencies compared to Laravel.

CodeIgniter 3 - Project Setup


1. Download from [Link]
2. Place folder in htdocs/www
3. Access via [Link]

CodeIgniter 3 - Folder Structure


- application/controllers/ → Controllers
- application/models/ → Models
- application/views/ → Views
- system/ → Core framework
- config/ → Configuration files

CodeIgniter 3 - Routing
Defined in application/config/[Link]

$route['default_controller'] = 'welcome';
$route['products'] = 'ProductController/index';

CodeIgniter 3 - Controller Example


class ProductController extends CI_Controller {
public function index() {
$this->load->view('product_list');
}
}
CodeIgniter 3 - Model Example
class ProductModel extends CI_Model {
public function getProducts() {
return $this->db->get('products')->result();
}
}

CodeIgniter 3 - Views Example


<html>
<body>
<h1><?php echo $title; ?></h1>
</body>
</html>

CodeIgniter 3 - Database
Config in application/config/[Link]

$this->db->insert('users', $data);
$query = $this->db->get('users');

CodeIgniter 3 - Interview Questions


- What is CodeIgniter and its advantages?
- Difference between CI3 and CI4?
- Explain MVC in CodeIgniter.
- How to implement sessions?
- What is hook in CodeIgniter?
- How do you perform form validation?
- How to use active record in CI3?

CodeIgniter 4 - Introduction
- Latest version (rewrite of CI3)
- Requires PHP >= 7.4
- Composer support
- Fully object-oriented

CodeIgniter 4 - Installation
composer create-project codeigniter4/appstarter project-root
php spark serve
CodeIgniter 4 - Folder Structure
- app/Controllers/ → Controllers
- app/Models/ → Models
- app/Views/ → Views
- app/Config/ → Config files
- public/ → Entry point

CodeIgniter 4 - Routing
Defined in app/Config/[Link]

$routes->get('/', 'Home::index');
$routes->get('products', 'ProductController::index');

CodeIgniter 4 - Controller Example


namespace App\Controllers;
use App\Models\ProductModel;

class ProductController extends BaseController {


public function index() {
$model = new ProductModel();
$data['products'] = $model->findAll();
return view('product_list', $data);
}
}

CodeIgniter 4 - Model Example


namespace App\Models;
use CodeIgniter\Model;

class ProductModel extends Model {


protected $table = 'products';
protected $primaryKey = 'id';
protected $allowedFields = ['name', 'price'];
}

CodeIgniter 4 - Views Example


<html>
<body>
<?php foreach($products as $product): ?>
<p><?= $product['name'] ?> - <?= $product['price'] ?></p>
<?php endforeach; ?>
</body>
</html>

CodeIgniter 4 - Database
Config in app/Config/[Link]

$db = \Config\Database::connect();
$query = $db->query("SELECT * FROM users");
$result = $query->getResult();

CodeIgniter 4 - Advanced Features


- CLI (php spark)
- Namespaces & Autoloading
- RESTful Controllers
- Improved security (CSRF, XSS filters)
- Better testing support

CodeIgniter 4 - Interview Questions


- Difference between CI3 & CI4?
- Explain lifecycle of CodeIgniter 4 request.
- What is spark CLI in CI4?
- How does CI4 handle namespaces?
- How do you build APIs in CI4?
- What are Entities in CodeIgniter 4?
- How to enable CSRF protection?
- How to use migrations in CI4?

You might also like