CodeIgniter Forums
CI4: Code Module is showing 404 in live server (cPanel) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: CI4: Code Module is showing 404 in live server (cPanel) (/showthread.php?tid=79795)



CI4: Code Module is showing 404 in live server (cPanel) - ciddict - 07-27-2021

I've added the module folder in ...\app\Config\Autoload.php

PHP Code:
public $psr4 = [
          APP_NAMESPACE => APPPATH// For custom app namespace
          'Config'      => APPPATH 'Config',
          'Blog'      => ROOTPATH 'example/Blog',
]; 

My directory:


Code:
/Home directory of main project folder
/example
    /Blog
        /Config
            /Routes.php
       /Controllers           
           /Blog.php


Routes.php


PHP Code:
namespace Config;

// Create a new instance of our RouteCollection class.
$routes Services::routes();

$routes->get('blog''blog::index', ['namespace' => 'Blog\Controllers']); 


Blog.php


PHP Code:
namespace Blog\Controllers;

class 
Blog extends \CodeIgniter\Controller {

    function index() { 
        echo "Code module";
    }




After running my_domain/index.php/blog, it's showing this error:

Code:
404 - File Not Found

Controller or its method is not found: \Blog\Controllers\blog::index

But it's working fine in my localhost server. 


RE: CI4: Code Module is showing 404 in live server (cPanel) - ciddict - 07-28-2021

Fixed the issue with this,
In Routes.php,
$routes->get('blog', 'blog::index', ['namespace' => 'Blog\Controllers']);
To,
$routes->get('blog', 'Blog::index', ['namespace' => 'Blog\Controllers']);


RE: CI4: Code Module is showing 404 in live server (cPanel) - InsiteFX - 07-28-2021

Correct, you must follow the case of the file names.