picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

How to debug? #626

Closed geoidesic closed 2 years ago

geoidesic commented 2 years ago

Hi there,

I'm running pico with Caddy, not Apache. I'm trying to debug PHP and not getting any logs or output.

If I do:

die('here');

in my plugin file, I just get a white screen, no output.

Is there any way I can get php errors to log to screen?

PhrozenByte commented 2 years ago

I'm afraid we can't provide general webserver configuration support as it isn't really related to Pico, sorry. You'll find a whole lot of info about this topic on the internet.

Just a quick hint: A white screen indicates some issue with PHP resp. the communication of PHP and your webserver. Check your webserver logs.

mayamcdougall commented 2 years ago

Not sure if this'll be helpful or not, but for my debugging I add the following to the top of Pico's index.php, just under the opening comments.

error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);

All it does is override the web server php configuration. In some cases, having a local override like this might be more convenient that modifying the config of the whole server. Definitely not recommended for production of course, but it usually works for some quick debugging. 😉

(And I may or may not just keep it there permanently in my testing Pico environment. 🙈)

yorikvanhavre commented 2 years ago

I also have a couple of issues with twig that I don't know how to debug..,

my theme & plugins works fine on my own computer, but most of it stops working once it's on the host server (some twig code is apparently not executing, but the page still displays). I'm using 3.0-alpha now, but the same problem occurs with 2.1

I suppose there is some difference in php setup between both machines, some missing extension that twig requires maybe, but how to debug that? Turning php errors on only shows some deprecation warnings, I tried to set debug: true and twig_config: debug: true in my config.yml file but I don't find any visible result of this... Does it log something somewhere?

Edit: It actually seems it's not a twig problem, but rather none of the plugins appears to be working (search and tags, basically). Still, any idea how to see what's wrong?

Edit2 My bad :facepalm: the plugins folder contained leftovers from some previous fiddling. Just cleaned it and all is working now, sorry for the noise

mayamcdougall commented 2 years ago

No worries. 😉

Glad you got everything working.

The Deprecated warnings on 3.0-alpha are expected (with errors enabled) if I remember right.

The debug option is just for passing through to Twig itself, it doesn't enable any extra functionality in Pico.

From the Twig Docs about Environment Options:

  • debug boolean

When set to true, the generated templates have a __toString() method that you can use to display the generated nodes (default to false).

I've never used this for anything, and I honestly don't know what it does (or if it does anything useful). As far as I know it's only really provided so that you can enable that flag if you needed to. It's not really intended to debug anything in Pico.

Anyway, don't be afraid to ask whatever other questions you might have. There's no such thing as a stupid question. 😁

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1: