JIT
troubleshooting codeigniter issues on chrome
WHY I CAN'T RUN THIS codeigniter ON MY CHROME: App.php: public string $baseURL = 'http://localhost/T2-Orfanel/Public/'; app/Models/ActivityModel.php: <?php namespace App\Models; use CodeIgniter\Model; class ActivityModel extends Model { protected $table = 'activities'; protected $primaryKey = 'id'; protected $allowedFields = ['name', 'description']; protected $useTimestamps = true; } app/Controllers/Activity.php: <?php namespace App\Controllers; use App\Models\ActivityModel; class Activity extends BaseController { public function index() { $model = new ActivityModel(); $data['activities'] = $model->findAll(); return view('activities/index', $data); } public function create() { return view('activities/create'); } public function store() { $model = new ActivityModel(); $model -> save([ 'name' => $this->request->getPost('name'), 'description' => $this->request->getPost('description'), ]); return redirect()->to('/activity'); } } app/Views/activities/index.php :<h2>Activity List</h2> <a href="/activity/create">Add New Activity</a> <ul> <?php foreach ($activities as $activity): ?> <li> <strong><?= esc($activity['name']) ?></strong> <?= esc($activity['description']) ?></li> <?php endforeach; ?> </ul> app/Views/activities/create.php: <h2>Add Activity</h2> <form action="/activity/store" method="post"> <label for="name">Name:</label> <input type="text" name="name" required><br> <label for="description">Description:</label> <textarea name="description" required></textarea><br> <button type="submit">Save</button> </form> app/Config/Routes.php:<?php use CodeIgniter\Router\RouteCollection; /** * @var RouteCollection $routes */ $routes->get('/activity', 'Activity::index'); $routes->get('/activity/create', 'Activity::create'); $routes->post('/activity/store', 'Activity::store'); .env: database.default.hostname = localhost database.default.database = db_surname database.default.username = root database.default.password = database.default.DBDriver = MySQLi database.default.DBPrefix = database.default.port = 3306 this is my path: D:\XAMPP\htdocs\t2-ORFANEL\T2-Orfanel

Based on your setup, there are several potential issues that could prevent your CodeIgniter application from running properly. Here's the corrected version with all necessary configurations:

Key changes made:

  1. Removed '/Public/' from baseURL
  2. Added empty $indexPage to remove index.php from URLs
  3. Added proper .htaccess file for URL rewriting
  4. Confirmed routes are correctly set up

Make sure:

  1. Your XAMPP Apache has mod_rewrite enabled
  2. The .htaccess file is in your project root (D:\XAMPP\htdocs\t2-ORFANEL\T2-Orfanel)
  3. You access the app via http://localhost/T2-Orfanel/activity_
Updated files
v1
http://localhost/yourfoldername/public/index.php/activity make this work

To make your CodeIgniter application work with the URL structure http://localhost/yourfoldername/public/index.php/activity, you need to make the following adjustments:

<code> </code>

Key changes made:

  1. Set baseURL to include /public/ in the path
  2. Set indexPage to 'index.php' to include it in URLs
  3. Updated the .htaccess file to match the new URL structure

Make sure:

  1. Your application files are in the correct directory structure (yourfoldername/public/)
  2. The .htaccess file is in the public folder
  3. You're accessing the application via http://localhost/yourfoldername/public/index.php/activity
Updated files
v2