CodeIgniter Forums
Controllers does not show when i use them in URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Controllers does not show when i use them in URL (/showthread.php?tid=77060)



Controllers does not show when i use them in URL - BlackBanana - 07-16-2020

In the Docs in this page

https://codeigniter.com/user_guide/incoming/controllers.html

the first example , i created the controller

PHP Code:
<?php namespace App\Controllers;

use 
CodeIgniter\Controller;

class 
Helloworld extends Controller
{
    public function index()
    {
        echo 'Hello World!';
    


then i visited this URI 

https://localhost/www/igniterTest/public/helloworld

But what is get was this

   

a 404 page

So where is the problem ? is it possible to access controllers without going through routes first ?


RE: Controllers does not show when i use them in URL - jreklund - 07-16-2020

Did you name your file Helloworld.php with a capital H? It won't work otherwise.

Have you disabled $routes->setAutoRoute(true); in App\Config\Routes? As it needs to be true, to automatically find it.


RE: Controllers does not show when i use them in URL - ChicagoPhil - 07-16-2020

Try
https://localhost/www/igniterTest/public/index.php/helloworld


RE: Controllers does not show when i use them in URL - BlackBanana - 07-16-2020

(07-16-2020, 07:18 AM)jreklund Wrote: Did you name your file Helloworld.php with a capital H? It won't work otherwise.

Have you disabled $routes->setAutoRoute(true); in App\Config\Routes? As it needs to be true, to automatically find it.

Yes its capital , the problem was in

$routes->setAutoRoute(false);


i made it

$routes->setAutoRoute(true);

thank you for help


RE: Controllers does not show when i use them in URL - BlackBanana - 07-16-2020

(07-16-2020, 12:02 PM)ChicagoPhil Wrote: Try
https://localhost/www/igniterTest/public/index.php/helloworld

The problem was in

$routes->setAutoRoute(true);

it was false , thank you


RE: Controllers does not show when i use them in URL - ChicagoPhil - 07-16-2020

(07-16-2020, 03:57 PM)BlackBanana Wrote:
(07-16-2020, 12:02 PM)ChicagoPhil Wrote: Try
https://localhost/www/igniterTest/public/index.php/helloworld

The problem was in

$routes->setAutoRoute(true);

it was false , thank you

That’s why the man has all those stars by his name. ?


RE: Controllers does not show when i use them in URL - BlackBanana - 07-16-2020

(07-16-2020, 10:20 PM)ChicagoPhil Wrote:
(07-16-2020, 03:57 PM)BlackBanana Wrote:
(07-16-2020, 12:02 PM)ChicagoPhil Wrote: Try
https://localhost/www/igniterTest/public/index.php/helloworld

The problem was in

$routes->setAutoRoute(true);

it was false , thank you

That’s why the man has all those stars by his name. ?


Yes he is an admin , of corse he has a vast experience in codeigniter, we should all help each other to give something to open source community


RE: Controllers does not show when i use them in URL - jreklund - 07-17-2020

Great that it all worked out. The amount of stars (and title) are based on number of posts. So if you keep on posting you will automatically get more stars and a new title.