Jump to content

Recommended Posts

Hey folks.

I've tried repeatedly to get error messages to show on a game that I'm working on. You know those messages that say something like "unexpected { or ;". Those kinds of messages. For that matter, I'm not getting any of the error messages to popup.

When there is an error in the code, I'm just getting a blank white screen. Now, if it's a minimum number of lines of code, it's usually easy enough to find, right. But when you have a lot of lines of code, you can spend hours by blocking certain code, trying it, then unblocking the next and so on to find the error.

Any ideas on what I can do to get this to work? Any help/suggestions would be greatly appreciated. Thanks a bunch.

Share this post


Link to post
Share on other sites

At the top of globals.php and globals_nonauth.php, add
 

ini_set('display_errors','On');
error_reporting(E_ALL & ~E_NOTICE);

If that doesn't work, and you have SSH access, I'd recommend installing the Composer package filp/whoops. 3 lines later, and you've got all the information you need.
I'd also recommend caution when using this as the default setup will expose raw code (perhaps lock the handler registration to your own ID/staff rank?)

If you don't have SSH access, or composer isn't an option, then check the Error Log. If the server on which the site is hosted is using cPanel, the Error Log can be easily accessed directly from within.
If that's not an option, then a logfile should be available within your system. Without knowing more about your setup, I can't really advise further

  • Like 2

Share this post


Link to post
Share on other sites

unexpected { or ; are pretty much game over as far as PHP is concerned and while logs help, packages have limited use here as syntax errors often prevent them from operating. I would suggest that any changes where you may be unsure you test locally. Assuming your local system works ... (you are testing aren't you?) ... then there should not be a problem - negating minor version differences in OS/PHP version etc. Next is to run your files through php -l:

find . -iname "*php" -exec php -l {} \;

this will point any any syntax errors in your code along with a handy line number that suggests where the problem is. You can also run this on a file-by-file basis with

php -l <filename>.php

If you are using git, it is possible to add this as a pre-commit hook which can save a few headaches.

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, newttster said:

Hey folks.

I've tried repeatedly to get error messages to show on a game that I'm working on. You know those messages that say something like "unexpected { or ;". Those kinds of messages. For that matter, I'm not getting any of the error messages to popup.

When there is an error in the code, I'm just getting a blank white screen. Now, if it's a minimum number of lines of code, it's usually easy enough to find, right. But when you have a lot of lines of code, you can spend hours by blocking certain code, trying it, then unblocking the next and so on to find the error.

Any ideas on what I can do to get this to work? Any help/suggestions would be greatly appreciated. Thanks a bunch.

Use PHPStorm and you'll have less as it highlights them magically!

  • Like 1

Share this post


Link to post
Share on other sites

My learned friend above is quite right; using PHP Storm can be a lifesaver in reducing the number of bugs reaching production; although I'd still point out that testing is ultimately key as many errors have been seen that escape Storm's otherwise beady eye.

Test, test and test again. Use PHPUnit for writing tests; use Xdebug for profiling your application; between the two you can produce test coverage in excess of 100% which makes future modifications, upgrades, additions etc a lot safer.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...