Closed Ningthem-Singh closed 1 year ago
It is just a misuse, not a bug.
See the screenshot. It shows not found: \Config\Home::index
.
The controller should be App\Controllers\Home
.
If you use ::class
keyword, you must specify the correct classname.
You need to learn PHP namespaces.
Yes I am new to this stuff but could you help in understanding why in some route it works and the in others it doesn't and i have to use the old technique/syntax. This is my routes.php
It is just a misuse, not a bug. See the screenshot. It shows
not found: \Config\Home::index
. The controller should beApp\Controllers\Home
. If you use::class
keyword, you must specify the correct classname. You need to learn PHP namespaces.
Because you don't understand PHP namespaces. It is not CI4 thing, but PHP thing. CI4 and modern PHP uses namespaces everywhere. So I recommend you learn namespacing completely.
Read:
P.S. If you show your code, do not use screenshots, but use copy and paste, please. And use Markdown properly.
Thank you for the knowledge shared by you.
And Yes i have got it I realized now why you kept saying namespaces even though I used it but only on the RegisterController
and I should have done the same for LoginController
and Home
as well.
And yes I have not used Markdown so much.
PHP Version
7.4, 8.0, 8.1
CodeIgniter4 Version
4.3.5
CodeIgniter4 Installation Method
Composer (using
codeigniter4/appstarter
)Which operating systems have you tested for this bug?
Windows
Which server did you use?
apache
Database
Maria DB 10.4.22
What happened?
Showing there is no route if i use the CodeIgniter 4 syntax which is
$routes->get('/', [Home::class, 'index']);
it doesn't work instead have to use the older syntax that is$routes->get('/', 'Home::index');
Steps to Reproduce
Instead of CI3 syntax in route if you use CI4 syntax there is error
Expected Output
As i am using CI4 it only wise to use the CI4 syntax instead of the older CI3 syntax
Anything else?
No response