Codeigniter 4 View file invalid
I'm not clear about your modules directory. Let’s say you want to keep a simple Faq module that you can re-use between applications. You might create folder with name, faq, to store all of your modules within. You will put it right alongside your app directory in the main project root:
/faq // modules directory
/app
/public
/system
/tests
/writable
Open app/Config/Autoload.php and add the Faq namespace to the psr4
array property:
$psr4 = [
'Config' => APPPATH . 'Config',
APP_NAMESPACE => APPPATH, // For custom namespace
'App' => APPPATH, // To ensure filters, etc still found,
'Faq' => ROOTPATH.'faq'
];
A common directory structure within a module will mimic the main application folder:
/faq
/modules
/Config
/Controllers
/Database
/Helpers
/Language
/Libraries
/Models
/Views
/Admin
/view_faq
View:
echo view('Faq\Modules\Views\view_faq', $data);