daveh / php-mvc

A simple PHP model-view-controller framework, built step-by-step as part of the "Write PHP like a pro: build an MVC framework from scratch" course on Udemy.
https://davehollingworth.com/go/phpmvc/
MIT License
782 stars 311 forks source link

How can i instance a Model method in a Controller ? #82

Closed roobiniano closed 3 years ago

roobiniano commented 3 years ago

Fatal error Uncaught exception: 'Exception'

Message: 'Method getAllAction not found in controller App\Controllers\User'

thats my controller :

`<?php

namespace App\Controllers;

use \Core\View;

/**

daveh commented 3 years ago

You need to reference the User model class in its own namespace - so this:

$users = \App\Models\User::getAll();

or add a use statement at the top to import it into the current namespace:

use App\Models\User;

roobiniano commented 3 years ago

You need to reference the User model class in its own namespace - so this:

$users = \App\Models\User::getAll();

or add a use statement at the top to import it into the current namespace:

use App\Models\User;

🤦‍♂️, thanks works perfectly, sorry, it was late when i was working the framwork is beatiful !