Welcome Guest, Not a member yet? Register   Sign In
Controller or its method is not found
#1

I’ve recently upgraded CodeIgniter from v4.3.8 to v4.4.0 and encountered an issue with routing.
My controller is located at app/Controllers/Member/Dashboard.php and is set up for auto-routing.

However, when I attempt to access the URL http://localhost:8080/member/dashboard, I receive the following error:

Code:
Controller or its method is not found: \App\ControllersMember\Dashboard::index

I’ve verified with
Code:
php spark routes
that the URL route is indeed defined.

Could someone guide me on how to resolve this?
Reply
#2

why
PHP Code:
\App\ControllersMember\Dashboard::index 
not
PHP Code:
\App\Controllers\Member\Dashboard::index 
Reply
#3

bring up my post
Reply
#4

Show the output of `php spark routes`, and the routing settings.
Reply
#5

(03-23-2024, 07:21 PM)kenjis Wrote: Show the output of `php spark routes`, and the routing settings.

here the result `php spark routes`
[Image: routes.png]

`app/Config/Routing.php`
[Image: routing.png]

and the result in browser
[Image: 404.png]
Reply
#6

Cannot reproduce.


PHP Code:
<?php

namespace App\Controllers\Member;

use 
App\Controllers\BaseController;
use 
CodeIgniter\HTTP\ResponseInterface;

class 
Dashboard extends BaseController
{
    public function index()
    {
        return __METHOD__;
    }


Code:
diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index fc4914a692..80226ae341 100644
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -5,4 +5,4 @@ use CodeIgniter\Router\RouteCollection;
/**
  * @var RouteCollection $routes
  */
-$routes->get('/', 'Home::index');
+//$routes->get('/', 'Home::index');
diff --git a/app/Config/Routing.php b/app/Config/Routing.php
index 47bf5ff8e5..e1941480f9 100644
--- a/app/Config/Routing.php
+++ b/app/Config/Routing.php
@@ -61,7 +61,7 @@ class Routing extends BaseRouting
      *
      * Default: false
      */
-    public bool $translateURIDashes = false;
+    public bool $translateURIDashes = true;

    /**
      * Sets the class/method that should be called if routing doesn't
@@ -89,7 +89,7 @@ class Routing extends BaseRouting
      *
      * If FALSE, will stop searching and do NO automatic routing.
      */
-    public bool $autoRoute = false;
+    public bool $autoRoute = true;

    /**
      * If TRUE, will enable the use of the 'prioritize' option

Code:
$ php spark routes

CodeIgniter v4.4.6 Command Line Tool - Server Time: 2024-03-25 01:28:52 UTC+00:00

+--------+------------------------------+------+------------------------------------------+----------------+---------------+
| Method | Route                        | Name | Handler                                  | Before Filters | After Filters |
+--------+------------------------------+------+------------------------------------------+----------------+---------------+
| auto  | /                            |      | \App\Controllers\Home::index            |                | toolbar      |
| auto  | home                        |      | \App\Controllers\Home::index            |                | toolbar      |
| auto  | home/index[/...]            |      | \App\Controllers\Home::index            |                | toolbar      |
| auto  | member/dashboard            |      | \App\Controllers\Member\Dashboard::index |                | toolbar      |
| auto  | member/dashboard/index[/...] |      | \App\Controllers\Member\Dashboard::index |                | toolbar      |
+--------+------------------------------+------+------------------------------------------+----------------+---------------+

Navigate to http://localhost:8080/member/dashboard,
I see
Code:
App\Controllers\Member\Dashboard::index
Reply
#7

(This post was last modified: 03-24-2024, 06:32 PM by kenjis.)

Upgrade to v4.4.6.

Auto Routing Legacy does not work in v4.4.0.
See https://codeigniter4.github.io/CodeIgnit...bugs-fixed
Reply




Theme © iAndrew 2016 - Forum software by © MyBB