![]() |
Public folder and assets for each module - 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: Public folder and assets for each module (/showthread.php?tid=92501) |
Public folder and assets for each module - kaligula - 02-24-2025 Hey guys. Have the next problem. I have several projects on my CMF based on CI4, I want to reconfigure it so that the root is in public as specified in the documentation. But the problem is that my CMF consists of modules (./modules), in which each module has its own assets folder (./modules/Test/Assets/jquery.min.js). I tried to switch the loading of these files through the php controller, but even on a local server there is a big delay. In Assets are: stylesheet, javascript, images. So when i switching to ./public as root folder, i can't access my modules assets.. RE: Public folder and assets for each module - luckmoshy - 02-24-2025 why too many public folders while all modules can use <link rel="stylesheet" herf="<?=base_url('assets/css.min.css')?> > RE: Public folder and assets for each module - kaligula - 02-24-2025 (02-24-2025, 11:22 AM)luckmoshy Wrote: why too many public folders while all modules can use <link rel="stylesheet" herf="<?=base_url('assets/css.min.css')?> > It's only because to create autonomous module system (only for admin system), so for example each module stores their own assets. I think i need something like on pyrocms assets manager (cache), maybe codeigniter 4 have something like that? RE: Public folder and assets for each module - luckmoshy - 02-24-2025 i think you may study this tool; it may help you enough It is for c4+ https://github.com/lonnieezell/Bonfire2/tree/develop or do like PHP Code: // app/Helpers/asset_helper.php app/Config/Routes.php PHP Code: $routes->get('modules/(:segment)/assets/(:any)', function ($module, $path) { usage PHP Code: // In app/Modules/Users/Views/users/profile.php for cahing PHP Code: if (! function_exists('module_asset')) { PHP Code: $routes->get('modules/cache/(:segment)/(:any)', function ($module, $path) { RE: Public folder and assets for each module - kaligula - 02-25-2025 Hey. About bonfire, i know this tool, but for me it very big, like fat cow, thats why i wrote my own CMF based on CI4. About response – very nice idea, so i can create a spark command for clean cache + create caches. But i don't understand, for development mode, how you can attach that files? Because all other files in the upper level then ./public. For example in development mode you need to include ./modules/Admin/TestModule/Assets/img/test-gif.svg, how you can do this? Each time check file for change time and copy like?: copy($fullPath, $cachePath); // Create cache if not exists or is older Will this put a load on my server? Because i trying to use readfile, as your last example – and simple empty page on the admin panel without calculating something – loading very slow (before readfile 2s, after – almost 5s) |