Welcome Guest, Not a member yet? Register   Sign In
How can I turn the debug bar on?
#11

(This post was last modified: 04-30-2020, 04:05 AM by Gary.)

Frustration is a big part of coding. I'd recommend wine, beer or something stronger, as required.

Any error/exception being thrown will break the toolbar if it stops script execution.

Your problem has to do with the paths that have (or have not) been correctly set somewhere, either in the CI framework, or in your server set-up (in one of the config files)... it may even be a problem in one of the .htaccess files (though that is probably an outside chance).

Also, whatever webserver you're on will have a lot of header-setting options that can be applied outside of the CI framework to tighten or relax security).

I'd suggest starting to look in App.php - there is a $baseURL variable spec'd there... and to get it working, perhaps checking $CSPEnabled=false is set (which I think is probably the default) - the idea is you want to have those two paths (in your cut&paste) the same (first prize), OR the CORS policy to be relaxed (as a temporary measure so you can work with the code).

Also, if need be, if you're using a local server (which I'm guessing you are, based on some of the cut&paste above), you can play with a remapping in your operating system's HOSTS file if necessary.
Reply
#12

Rename env to .env and add CI_ENVIRONMENT = development

And then in app/Config/App.php put correct baseUrl... for example

app.baseURL = "http://localhost/your-project/public/"

and I'm sure debug toolbar will start to work Wink
Reply
#13

(This post was last modified: 04-30-2020, 07:33 AM by YanKleber.)

(04-29-2020, 05:36 PM)Gary Wrote: Frustration is a big part of coding. I'd recommend wine, beer or something stronger, as required.

Haha, SURE! Old timer coder here so I year ya... unfortunately no alcohol around...  Angel 


(04-29-2020, 05:36 PM)Gary Wrote: Any error/exception being thrown will break the toolbar if it stops script execution.

Your problem has to do with the paths that have (or have not) been correctly set somewhere, either in the CI framework, or in your server set-up (in one of the config files)... it may even be a problem in one of the .htaccess files (though that is probably an outside chance).

Also, whatever webserver you're on will have a lot of header-setting options that can be applied outside of the CI framework to tighten or relax security).

I'd suggest starting to look in App.php - there is a $baseURL variable spec'd there... and to get it working, perhaps checking $CSPEnabled=false is set (which I think is probably the default) - the idea is you want to have those two paths (in your cut&paste) the same (first prize), OR the CORS policy to be relaxed (as a temporary measure so you can work with the code).

Also, if need be, if you're using a local server (which I'm guessing you are, based on some of the cut&paste above), you can play with a remapping in your operating system's HOSTS file if necessary.


Cool, that's a great tip. I will check my configuration files and paths and see what happens. I'll update this thread accordingly with my improvements (or more frustrations).

Big Grin
Recovering the wasted time...
Reply
#14

(04-29-2020, 05:36 PM)Gary Wrote: I'd suggest starting to look in App.php - there is a $baseURL variable spec'd there... and to get it working, perhaps checking $CSPEnabled=false is set (which I think is probably the default) - the idea is you want to have those two paths (in your cut&paste) the same (first prize), OR the CORS policy to be relaxed (as a temporary measure so you can work with the code).

Gary, you absolutely nailed it. Believe it or not the problem was fixed in my very first attempt!

I opened the app.php file and went directly to $baseURL. There I realized that it was configured to point to 'http://localhost/curso-codeigniter4/'. The problem is that I already had configured before my local server (XAMPP) to a virtual host called 'http://curso-ci4/'.

Long story short, as soon I changed $baseURL to point to the virtual host it worked instantly in the very first F5 stroke.

Now I have the small flame at the bottom right bar of my screen and all the odd errors in console has vanished! Big Grin 

Thanks for the detailed instructions!

Cool
Recovering the wasted time...
Reply
#15

Hello,

I am discovering CodeIgniter and would like to use it for my app so began tutorial and all worked fine until I have the same problem (no debug bar).

I have checked my files for all that is mentionned here, but all seems to be ok :

In .env :
CI_ENVIRONMENT = development
app.baseURL = 'http://localhost'

In App.php :
$baseURL = 'http://localhost:8080'

 In htacess files :
I found nothing about CI_ENVIRONMENT

In Filter class (globals array) :
'toolbar' is uncommented.

CI development server is started at http://localhost:8080.

Nevertheless my browser console indicates that message : GET http://localhost/index.php?debugbar net::ERR_CONNECTION_REFUSED

Can you please tell me what's going wrong?


Thank you in advance.



:
Reply
#16

If it is a CORS problem you can add this to your .htaccess file for now, better ones are in the works.
Add it under RewriteBase /
Code:
## .htaccess Control For CORS Configuration

# Add Font Awesome Font Types
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf        .ttf
AddType application/x-font-opentype  .otf
AddType application/font-woff        .woff
AddType application/font-woff2        .woff2

<IfModule mod_headers.c>
        <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg|svgz|jpg|png|ico|font.css|css|js)$">
            ## un-remark this one for all access and remark out the one below it
            ## very un-secure!!!
            #Header set Access-Control-Allow-Origin "*"
            ## Change this to your local host url. and https or http
            Header add Access-Control-Allow-Origin: "https://yoursite.com"
            Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
            Header add Access-Control-Allow-Headers: "Upgrade-Insecure-Requests"
        </FilesMatch>
</IfModule>

Change https://yoursite.com to your website.com
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#17

(02-17-2023, 02:24 AM)InsiteFX Wrote: If it is a CORS problem you can add this to your .htaccess file for now, better ones are in the works.
Add it under RewriteBase /
Code:
## .htaccess Control For CORS Configuration

# Add Font Awesome Font Types
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf        .ttf
AddType application/x-font-opentype  .otf
AddType application/font-woff        .woff
AddType application/font-woff2        .woff2

<IfModule mod_headers.c>
        <FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|svg|svgz|jpg|png|ico|font.css|css|js)$">
            ## un-remark this one for all access and remark out the one below it
            ## very un-secure!!!
            #Header set Access-Control-Allow-Origin "*"
            ## Change this to your local host url. and https or http
            Header add Access-Control-Allow-Origin: "https://yoursite.com"
            Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
            Header add Access-Control-Allow-Headers: "Upgrade-Insecure-Requests"
        </FilesMatch>
</IfModule>

Change https://yoursite.com to your website.com

Thank you InsiteFX. I have added those lines but nothing has changed.
Reply
#18

(This post was last modified: 03-11-2024, 06:17 PM by ben_ci.)

go to .env file

Code:
CI_ENVIRONMENT = development

Code:
app.baseURL = 'http://localhost/<your project folder name>/'

only run using http
Code:
app.forceGlobalSecureRequests = false


set the permission for writable folder.
Code:
chmod -R 775 writable

run the dev server by,
Code:
php spark serve

if it is not showing, commented it
Code:
#app.baseURL = ''

!! Make sure you remove the # before setting the above variables and the app is running in port 8080
Reply




Theme © iAndrew 2016 - Forum software by © MyBB