Hey Guys,
im still new to CodeIgniter... I finally got it working on my live server (.htdocs, seperating folders etc.) with a VueJs frontend.
Now, currently im able to access the "user/login" route with which I authenticate the user credentials and return a a bearer token, which is working quite fine.
But if i try to add a new controller function, like, getUsers or getUser/testUser, or anything else, i always get the error code 500: Undefined property: App\\Controllers\\User::$load
Following are the User Controller and the Routes.php config:
PHP Code:
<?php namespace App\Controllers;
use \App\Libraries\OAuth2Server;
use \OAuth2\Request;
use \CodeIgniter\API\ResponseTrait;
class User extends BaseController {
use ResponseTrait;
public function login() {
$oauth2Server = new OAuth2Server();
$request = new Request();
$respond = $oauth2Server->server->handleTokenRequest($request->createFromGlobals()); #See Doc https://bshaffer.github.io/oauth2-server-php-docs/
$code = $respond->getStatusCode();
$body = $respond->GetResponseBody();
#Ci4 Feature used for API Response
return $this->respond(json_decode($body), $code);
}
public function getUsers() {
$userModel = model('UserModel');
foreach($this->UserModel->getAllUsers() as $user) {
$user["username"] = $user->username;
$user["first_name"] = $user->first_name;
$user["last_name"] = $user->last_name;
$user["email"] = $user->email;
}
return $this->respond(json_encode($user));
}
}
Here are the Routes:
PHP Code:
$routes->setDefaultNamespace('App\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(false);
$routes->set404Override();
$routes->setAutoRoute(true);
$routes->get('/', 'Home::index');
$routes->get('user/login', 'User::login');
$routes->get('user/getUsers', 'User::getUsers');
$routes->resource('testtabelle');
Please, for the love of god, what am i doing wrong here?