I am using codeigniter 4 with modules.I am getting error invalid file :Admin/valid_faq.php What is wrong in the view path? My Module structure is like below
app
--modules
-- Faq
--controller
--Models
--Views
--Admin
--view_faq
echo view('layout/header', $data);
echo view('layout/sidebar');
echo view('Admin/view_faq', $data);
echo view('layout/footer');
I have gave the full path then also it doesn't work.
echo view('App/Modules/Faq/Views/Admin/view_faq');
echo view('Modules/Faq/Views/Admin/view_faq');
I have added to Autoload as well
public $psr4 = [
APP_NAMESPACE => APPPATH, // For custom app namespace
'Config' => APPPATH . 'Config',
'Modules' => APPPATH . 'Modules',
];
When I checked the view file
SYSTEMPATH\Common.php : 1121 — CodeIgniter\View\View->render ( arguments )
F:\xampp\htdocs\modularcms\app\Config/../Views/Modules/Faq/Views/Admin/view_faq.php
This is working
echo view('../Modules/Faq/Views/Admin/view_faq', $data);
my view directory in the paths
public $viewDirectory = __DIR__ . '/../Views';
Error function
public static function renderer(string $viewPath = null, $config = null, bool $getShared = true)
{
if ($getShared)
{
return static::getSharedInstance('renderer', $viewPath, $config);
}
if (is_null($config))
{
$config = new \Config\View();
}
if (is_null($viewPath))
{
$paths = config('Paths');
$viewPath = $paths->viewDirectory;
}
return new \CodeIgniter\View\View($config, $viewPath, static::locator(), CI_DEBUG, static::logger());
}