CodeIgniter Forums
myth/auth service not working and return null - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: myth/auth service not working and return null (/showthread.php?tid=79969)



myth/auth service not working and return null - takbitdev - 08-26-2021

Hello everyone
Myth/auth
Auth\Controllers\AuthController.php : ~ 29
$this->config = config('Auth');
$this->auth = service('authentication');

if ($this->auth->check()) : ~ 46

This two lines return null and this error message: Call to a member function check() on null


RE: myth/auth service not working and return null - takbitdev - 08-27-2021

Solved.
In Linux system, paths must contain / but my local machine have Windows and in windows system paths have \ .
Just modify the psr4 paths:

In Windows server:

public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'App'        => APPPATH, // To ensure filters, etc still found,
'Config'      => APPPATH .'Config',
'Addon'      => ROOTPATH .'addon',
'Blog'        => ROOTPATH .'addon\Blog',
'Auth'    => ROOTPATH .'addon\Auth'
];

In Linux server:

public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'App'        => APPPATH, // To ensure filters, etc still found,
'Config'      => APPPATH .'Config',
'Addon'      => ROOTPATH .'addon',
'Blog'        => ROOTPATH .'addon/Blog',
'Auth'    => ROOTPATH .'addon/Auth'
];


RE: myth/auth service not working and return null - paulbalandan - 08-27-2021

you can use the DIRECTORY_SEPARATOR constant instead of changing it manually in between servers