Welcome Guest, Not a member yet? Register   Sign In
Controllers does not show when i use them in URL
#1

(This post was last modified: 07-16-2020, 07:44 PM by BlackBanana.)

In the Docs in this page

https://codeigniter.com/user_guide/incom...llers.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 ?
Increase Your Awareness
Reply
#2

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

(This post was last modified: 07-16-2020, 12:15 PM by jreklund.)

Try
https://localhost/www/igniterTest/public...helloworld
Reply
#4

(This post was last modified: 07-16-2020, 07:43 PM by BlackBanana.)

(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
Increase Your Awareness
Reply
#5

(This post was last modified: 07-16-2020, 07:42 PM by BlackBanana.)

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

The problem was in

$routes->setAutoRoute(true);

it was false , thank you
Increase Your Awareness
Reply
#6

(07-16-2020, 03:57 PM)BlackBanana Wrote:
(07-16-2020, 12:02 PM)ChicagoPhil Wrote: Try
https://localhost/www/igniterTest/public...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. ?
Reply
#7

(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...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
Increase Your Awareness
Reply
#8

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




Theme © iAndrew 2016 - Forum software by © MyBB