![]() |
Where to put message file in codeigniter4? - 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: Where to put message file in codeigniter4? (/showthread.php?tid=87776) |
Where to put message file in codeigniter4? - mayurkoshti - 05-31-2023 I want to create a separate file called custom_message.php. What will be the location of this file in CI4 project structure and how to call in controller. Example:
Code: $arr_custom_message = [ RE: Where to put message file in codeigniter4? - InsiteFX - 05-31-2023 You can create your own folder under the app folder app/Messages And place your files there. RE: Where to put message file in codeigniter4? - mayurkoshti - 06-02-2023 (05-31-2023, 11:34 PM)InsiteFX Wrote: You can create your own folder under the app folder Thanks! RE: Where to put message file in codeigniter4? - InsiteFX - 06-03-2023 Don't forget you can also have your own Modules. RE: Where to put message file in codeigniter4? - Muzikant - 06-05-2023 Hi. For simple messages like this you can use config file dedicated to messages. Create: App/Config/CustomMessages.php PHP Code: <?php Usage in your controller: PHP Code: // ... RE: Where to put message file in codeigniter4? - ikesela - 06-05-2023 suggesting using language file is easier. create file in folder folder: App\Language\en\message.php File content: return [ 'add' => 'Admin Created!', 'update' => Updated Successfully!' ]; calling: <?=lang('message.add')?> <?=lang('message.update')?> * language/localization is flexible, can pass value to message This from guide: Code: <?php |