CodeIgniter Forums
Hi Just installed CI, added a controller, see 404 - 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: Hi Just installed CI, added a controller, see 404 (/showthread.php?tid=90553)



Hi Just installed CI, added a controller, see 404 - cndv3996 - 04-01-2024

Hi Guys,
I'm pretty new to CI. Really thanks that we have this forum.
I just installed this version: codeigniter4-framework-v4.4.7-0-ge6a2f70
I use Apache to host web service.
Following instructions, changed AllowOverride to All in Apache configuration.
Changed web document root to "public" folder.
With "localhost" I can call out IG welcoming page.
But as I added an Act "editor":
PHP Code:
namespace App\Controllers;

class 
Home extends BaseController
{
    public function index(): string
    
{
 
        return view('main');
    }
 
 public function 
editor()
    {
        echo "check";
        //return view('editor');
    }

I call it with:
http://localhost/editor
or
http://localhost/Home/editor
or
http://localhost/index.php/Home/editor
I only see:
404

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

I also tried to add another controller:
PHP Code:
namespace App\Controllers;

class 
Editor extends BaseController
{
    public function index(): string
    
{
        return view('welcome_message');
    }


I call it with:
http://localhost/Editor
or
http://localhost/index.php/Editor
I again, see:
404

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

I don't read ".htaccess" fluently, anything I can do?
Thank you!


RE: Hi Just installed CI, added a controller, see 404 - kenjis - 04-01-2024

If you are new to CodeIgniter4, try this tutorial:
https://codeigniter4.github.io/CodeIgniter4/tutorial/index.html

By default, you need to write routes for the controller method.
See https://codeigniter4.github.io/CodeIgniter4/tutorial/static_pages.html#setting-routing-rules


RE: Hi Just installed CI, added a controller, see 404 - cndv3996 - 04-01-2024

(04-01-2024, 09:41 PM)kenjis Wrote: If you are new to CodeIgniter4, try this tutorial:
https://codeigniter4.github.io/CodeIgniter4/tutorial/index.html

By default, you need to write routes for the controller method.
See https://codeigniter4.github.io/CodeIgniter4/tutorial/static_pages.html#setting-routing-rules

Thank you for the information.
I add a new router:
$routes->get('/Editor', 'Editor::index');

Then I see the new controller!