CodeIgniter Forums
Auto Routing Not Working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Auto Routing Not Working (/showthread.php?tid=92232)



Auto Routing Not Working - WhoAmI - 12-26-2024

I'm a veteran of CI3, but CI4 (4.4.7) is giving me all sorts of problems.

So I followed the directions to enable Auto Routing (Improved):

https://codeigniter.com/user_guide/incoming/routing.html#enable-auto-routing

I then followed the instruction to create HelloWorld Controller:

https://codeigniter.com/user_guide/incoming/controllers.html#controller-auto-routing-improved


Quote:    Let’s try it: Hello World

    Let’s create a simple controller so you can see it in action. Using your text editor, create a file called Helloworld.php, and put the following code in it. You will notice that the Helloworld Controller is extending the BaseController. you can also extend the CodeIgniter\Controller if you do not need the functionality of the BaseController.

    The BaseController provides a convenient place for loading components and performing functions that are needed by all your controllers. You can extend this class in any new controller.

    <?php

namespace App\Controllers;

class Helloworld extends BaseController
{
public function getIndex()
{
return 'Hello World!';
}
}

    Then save the file to your app/Controllers directory.Let’s try it: Hello World!

    Let’s create a simple controller so you can see it in action. Using your text editor, create a file called Helloworld.php,
    and put the following code in it. You will notice that the Helloworld Controller is extending the BaseController. you can
    also extend the CodeIgniter\Controller if you do not need the functionality of the BaseController.

    The BaseController provides a convenient place for loading components and performing functions that are needed by all your
    controllers. You can extend this class in any new controller.

    <?php

namespace App\Controllers;

class Helloworld extends BaseController
{
public function getIndex()
{
return 'Hello World!';
}
}

Then save the file to your app/Controllers directory.

    Now visit your site using a URL similar to this:

    example.com/index.php/helloworld

    If you did it right you should see:

    Hello World!
    Now visit your site using a URL similar to this:
    example.com/index.php/helloworld

If you did it right you should see:
Hello World!

Well, I did NOT see Hello World!

Instead it says,

    404

    Sorry! Cannot seem to find the page you were looking for.

Please help


RE: Auto Routing Not Working - InsiteFX - 12-26-2024

You should upgrade to the newer CodeIgniter 4.5.5 version.