Fairly frequently I dive into the Grav API documentation but for some reason, which for a large part is my limited dev knowledge, I can’t make the connection with the rest of the documentation. I hope I have been looking on the wrong places. Any hints are greatly appreciated! Thanks.
Everything I learned about this I learned by looking at other plugins and trial and error. This is only mentioned in the main docs in one, nonintuitive place. The team is pretty open to pull requests against the docs, if you have some ideas for improvement.
It’s nice to know that I’m not the only one who is struggling. Regarding the docs, these are pretty good. What I need are more examples like you are doing in the Cookbook. Great work.
The Grav Debug bar is very helpful as I often do things like:
Yes, dump() is handy as well. Right now I do a lot of testing with AJAX requests and so dump() and the Debug bar are of little use.
So, only if you promise not to laugh, I’ll let you (all) in on my debug method:
#start buffering (all activity to the buffer)
ob_start() ;
# dumps to buffer
var_dump('ROUTE: '.$target_dir) ;
# dump buffered $classvar to $outStringVar
$outStringVar = ob_get_contents() ;
# open your file with append, read, write perms
# (be sure to check your file perms)
$fp=fopen('mylog.html','a+');
# write output to file & close it
fwrite($fp, $outStringVar );
fclose($fp);
# clean the buffer & stop buffering output
ob_end_clean() ;
By examining the file my log.html I can test things an d learn a lot while at the same time I know there must be better ways than this…