Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter 4 assets PATH configuration for Modules

I m creating different directories for Role-based access in Codeigniter 4. I have created the Modules directory inside app/ i.e (app/modules/admin). I have assets for the admin. I want to load it in the header file of view. I have tried it with the base_url().'/app/modules/admin/assets/filename.xyz' but load the complete file in the link but doesn't show me the assets. How can, I load these assets in the same directory. Please see the below code

<link rel="stylesheet" href="<?php echo(base_url().'/app/modules/super/assets/'); ?>plugins/fontawesome-free/css/all.min.css">

like image 604
Mansoor Ahmad Avatar asked May 29 '26 21:05

Mansoor Ahmad


1 Answers

All public files including assets should be placed inside your public folder and not your app folder. Your app folder shouldn't be visible to the public.

With this in mind what I would do would be create a simular structure in your public folder.

public/modules/admin/css
public/modules/admin/js
public/modules/admin/img

Then if you have an asset called styles that would be in:

public/modules/admin/css/styles.css

This asset should be called using the base_url function from the uri helper.

<link src="<?php echo base_url('modules/admin/css/styles.css'); ?>">
like image 97
marcogmonteiro Avatar answered Jun 02 '26 20:06

marcogmonteiro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!