Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Class 'App\Entities\Tasks' not found in D:\xampp\htdocs\tasks\system\...
#1
Question 
(This post was last modified: 04-19-2022, 03:44 AM by Ahmed Haroon.)

it is showing below error when trying to run app in browser.

Fatal error: Class 'App\Entities\Tasks' not found in D:\xampp\htdocs\tasks\system\Database\MySQLi\Result.php on line 148

i am following a udemy course, when it guide for Entities i created a file App\Entities\Tasks.php and made some changes as instructed, it was my mistake i created it with same name as my Controller file Tasks.php , when it instructed to  use this in the Controller it was showing error that class is already exists and it was not saving the file in Controller\Tasks.php which is obvious. 
i rename file App\Entities\Tasks.php to Task.php in its folder , made change in the new method in Controller and it saved, when run it is now showing above error. i search for word Entities in all files but it is only in my main Controller file which is Tasks.php and it appear here only once, i have modified it to Task.php but still it is showing above error. shutdown Apache and MySQL from xampp controller, Quit it and run again, start both servers and in another browser trying to run, but still it is showing same error. 
now there is no file App\Entities\Tasks.php  instead now it has App\Entities\Task.php 
please help to resolve this problem, this is in system folder and i have instructed not to touch any file in this folder.

[Image: CI4-Error.jpg]
regards
Reply
#2

If you don't have app\Entities\Tasks.php, the Class 'App\Entities\Tasks' would be not found.
And you must write the correct namespace and correct classname in it.
Reply
#3

(This post was last modified: 04-19-2022, 04:07 AM by Ahmed Haroon.)

@kenjis as wrote above, i has been done already. i have renamed App\Entities\Tasks.php to App\Entities\Task.php 
i have a file App\Entities\Task.php and in Controller: use App\Entities\Task; in method new i have $tasks = new Task;
hope that clear.
regards

[Image: CI4-Error2.jpg]
Reply
#4

Code:
Fatal error: Class 'App\Entities\Tasks' not found in D:\xampp\htdocs\tasks\system\Database\MySQLi\Result.php on line 148

You are using Class 'App\Entities\Tasks', not 'App\Entities\Task'.

If you want to use 'App\Entities\Task, change the classname that causes the above error.
It may be in your Model?
Reply
#5

(This post was last modified: 04-19-2022, 09:45 PM by Ahmed Haroon.)

(04-19-2022, 05:20 AM)kenjis Wrote:
Code:
Fatal error: Class 'App\Entities\Tasks' not found in D:\xampp\htdocs\tasks\system\Database\MySQLi\Result.php on line 148

You are using Class 'App\Entities\Tasks', not 'App\Entities\Task'.

If you want to use 'App\Entities\Task, change the classname that causes the above error.
It may be in your Model?

@kenjis thank you for your passions to guide me.
you can seen in screenshot, on left side i marked in red circle this is in 'App\Entities\Task.php' not 'App\Entities\Tasks.php' 
on right side, there is Controller class file which name is 'App\Controller\Tasks.php' in this Controller class i am using 'App\Entities\Task.php' 

good news is problem resolved, i created new project and one-by-one added all files (with testing step-by-step), now problem resolved.
and more beautiful thing is i learned now (to minimize and more manageable code) to have 
- one common layout file to use in different Views
- one common form file to use in both Add/Edit views
which i was asking in my thread earlier Previous Thread

regards
Reply




Theme © iAndrew 2016 - Forum software by © MyBB