Tutorial (Class 'App\Models\NewsModel' not found) |
Good morning, is anyone already testing CI4 and managed to do the documentation tutorial?
I followed the tutorial at https://bcit-ci.github.io/CodeIgniter4/t...index.html I'm having trouble trying to use the Model, I'm getting the error that the Model class could not be found. I'm starting to test this new version of CI, as the way we loaded the Model changed, I wonder if anyone had the problem and solved it. Thank you very much in advance Controller PHP Code: <?php Model PHP Code: <?php
You didn't namespace your model. Assuming your model is stored at applications/Models/NewsModel.php, you should have this line at the very top of the file:
Code: namespace App\Models; That's how the application knows where to find it.
Thanks, I did not notice.
I would like to congratulate you for the excellent Framework.
No problem. And it wasn't in there at the time. I've updated the tutorial though so others should be able to follow along with a little less problems.
Hi
I just spent an hour before I found this post that helped me. In the tutorial on: https://codeigniter4.github.io/CodeIgnit...ction.html It would be nice if PHP Code: namespace App\Models; is in the code for the model above: PHP Code: use CodeIgniter\Model; And CI4 looks very promising Kim
Fix applied to development version, and is now reflected in the development user guide ... https://codeigniter4.github.io/CodeIgnit...ction.html
I am on very start of learning this grate framework, but have some problems.
I have similar problem, cant understand what is problem, can someone help please? Model: Location: app\Models\Main\ToolsModel.php Code: <?php Controller: Location: app\Controllers\Main\MainController.php Code: <?php I tryed many ways for namespace and use, nothing works, in controller colored text: Model in use App\Models; and written Undefined class 'Models' What am i doing wrong and how to fix? |
Welcome Guest, Not a member yet? Register Sign In |