Public folder and assets for each module |
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..
why too many public folders while all modules can use <link rel="stylesheet" herf="<?=base_url('assets/css.min.css')?> >
Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
(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?
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) { Codeigniter First, Codeigniter Then You!!
yekrinaDigitals
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) |
Welcome Guest, Not a member yet? Register Sign In |