Honestly, I don't see any reasons why it shouldn't work? All static method can be use by other classes. Except, if this is a separate controller file /login . That would change the application's loaded controller.
It is pretty much equivalent to
<form method="post" action="/login">
On form submit, it would take you to /application_directory/login_Controller/Method/. In your case you are loading the login controller instance. If the login controller page does not require the User class, then User::login() method cannot be executed.
I wrote an application on CI where the user can login and will never leave the page. To do this, you make the method of the current controller page that will process the form.
So, for instance a URI appdirectory/login_controller/ can process the form by assigning the processing to another method called process. That would give us a new uri of /appdirectory/login_controller/process/. However, even after the form has been processed, the controller page did not change and we are still using the same controller. Only the method process is added.
If the login_controller file require the User class, then the static method of User should be available.
Example class uitilizing static method of another class: This is an example only. Your framework may have different ways of doing things.
require_once('user.php');
class LoginController extends BaseController{
public function __construct(){}
public function index(){
echo 'this is the default content on load';
}
public function process(){
echo 'This is the form processor';
if(isset($email) AND (isset($password)){
User::login($email, $password);
}
}
}
The …