Welcome Guest, Not a member yet? Register   Sign In
CI4: Code Module is showing 404 in live server (cPanel)
#1

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. 
Reply
#2

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']);
Reply
#3

Correct, you must follow the case of the file names.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB