05-13-2020, 12:09 AM
I have asked the following question at stackoverflow: https://stackoverflow.com/questions/6176...irectories
I have following Codeigniter 4 project structure. I am having problem with using base_url() and setting app.baseURL in .env file properly. Following two questions are due to this same problem:
Project Structure
wamp-web-root
ci_4_project
public
app
assets
APP Structure
public
system
app
Controllers
First_controller.php
Subfolder1
Subfolder2
Subfolder3
Second_controller.php
FIRST QUESTION - controller sub-directories
My First_controller.php
works fine but my Second_controller.php
is not working.
SECOND QUESTION - accessing assets folder
I use following code to include css files in my views:
In my .env file: if I use app.baseURL = 'http://localhost/ci_4_project/public/' then Codeigniter Debug Toolbar is displayed but css files are not included in views. If I use app.baseURL = 'http://localhost/ci_4_project/' i.e. without appending public then css files are included in views but Codeigniter Debug Toolbar is not displayed. Apparently this is because assets folder is not inside public folder but instead at same level so when I use public in baseURL, assets are not included. My question is: how to define app.baseURL and whether to add public or not in the url.
I have following Codeigniter 4 project structure. I am having problem with using base_url() and setting app.baseURL in .env file properly. Following two questions are due to this same problem:
Project Structure
wamp-web-root
ci_4_project
public
app
assets
APP Structure
public
system
app
Controllers
First_controller.php
Subfolder1
Subfolder2
Subfolder3
Second_controller.php
FIRST QUESTION - controller sub-directories
My First_controller.php
Code:
<a href="<?php echo base_url()."/public/first_controller";?>">Link</a>"
Code:
<a href="<?php echo base_url()."/public/subfolder1/subfolder2/subfolder3/second_controller";?>">Link</a>"
SECOND QUESTION - accessing assets folder
I use following code to include css files in my views:
Code:
<link href="<?php echo base_url();?>/assets/bootstrap-4.4.1/css/bootstrap.css" rel="stylesheet">
In my .env file: if I use app.baseURL = 'http://localhost/ci_4_project/public/' then Codeigniter Debug Toolbar is displayed but css files are not included in views. If I use app.baseURL = 'http://localhost/ci_4_project/' i.e. without appending public then css files are included in views but Codeigniter Debug Toolbar is not displayed. Apparently this is because assets folder is not inside public folder but instead at same level so when I use public in baseURL, assets are not included. My question is: how to define app.baseURL and whether to add public or not in the url.