Remove C:\inetput\... from php errors - php

How would I remove part of the directory path before my actual php script when showing php errors?
For instance:
PHP Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to load system boot file' in C:\inetpub\Ruby\public_html\websites\local\index.php:8
I would rather have it show only this path: ..\websites\local\index.php:8 (in addition to the rest of the error message of course).
I realize I should not show these errors on a public or non-development server, but I would like to increase readability of these errors during development.

Related

Symfony Uncaught PHP Exception ErrorException at session_start()

I've been getting this error: REQUES Uncaught PHP Exception ErrorException: "Warning: Erroneous data format for unserializing 'Ramsey\Uuid\Lazy\LazyUuidFromString'" at C:\Users\Alex\Desktop\ALM\ALM-proto\vendor\symfony\http-foundation\Session\Storage\NativeSessionStorage.php line 153 whenever I run my symfony server. It prevents my localhost:8000 page from loading. I've opened the file from the error message and found out that this block of code is the culprit. By commenting it out, I no longer see the error, and the page loads. However, because I don't have access to the session, it causes other problems. So I need this block of code of code to work. How can I fix this?
if (!session_start()) {
throw new \RuntimeException('Failed to start the session');
}
Here are my Symfony project specs:
Symfony 4.3.11
PHP 7.4.16
Composer 2.0.11
OS: Windows 10

Duplicate entries in PHP error_log using set_exception_handler

I cannot seem to locate the source of this issue. I actually have nearly the same Docker container and Exception handler lib running in another app. However, for some reason, I'm getting duplicate log entries in the error log file.
The issue is that it's not just duplicate entries that are the same (that'd be another interesting issue). It's the same Exception being logged and the same stack trace, but one is from my custom Exception handler (JSON), and the other is the default PHP error log handler (or so it seems - tested with CLI SAPI as well as PHP-FPM).
I was under the assumption that PHP wouldn't write to the log file if an exception handler was set. I'm also executing die(1) at the end of the callback function for the Exception handler.
Again, all of the Exception handling code seems to be working well. It's just that PHP is still logging the Exception. Is there a setting or something else that I'm missing here needing to be done on the PHP config side?
Below is a copy of the error log output:
[24-Nov-2018 02:20:11 UTC] PHP Exception: Testing in /srv/www/boot/common.php on line 65
[24-Nov-2018 02:20:11 UTC] PHP Stack trace:
[24-Nov-2018 02:20:11 UTC] PHP 1. {main}() /srv/www/public/index.php:0
[24-Nov-2018 02:20:11 UTC] PHP 2. require() /srv/www/public/index.php:13
{"timestamp":"2018-11-24 02:20:11 UTC","level":"critical","message":"Testing","app_version":{},"environment":"dev","class":"Exception","file":"\/srv\/www\/boot\/common.php","line":65,"code":0,"previous":null,"trace":[{"file":"\/srv\/www\/public\/index.php","line":13,"function":"require"}],"user":[],"tags":[],"extra":[],"output_buffers":[]}
Going to leave this here for anyone that might come across this. The issue turned out to be XDebug which hijacks your Exceptions. It was enabled on this particular app in our dev env.

PHP errors in Nginx error log instead of Monolog log files

I'm getting a following error in my application:
2018/08/31 06:13:24 [error] 20208#20208: *139993 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function setTime() on boolean in /var/www/website.com/releases/20180829221434Z/src/Somenamespace/SomeClass.php:218
Of course, I understand that this is a problem in my code and I have to fix it, but what bothers me is that this exception is not caught and logged by Monolog, but instead it ends up in Nginx log.
My questions are:
1. Is is even possible that Monolog catches and logs this kind of error?
2. If the first one is positive, is there any particular configuration in PHP (7.0.18) of Symfony (3.4) that should be applied for my application?

Showing fatal PHP errors in GAE appengine logs

In local dev environment I see php errors from a call to an external REST service (payment gateway). This is dumped on my browser as expected and shows up in the log console (GAE launcher) - no problem.
Fatal error: Uncaught exception 'Paybrkr\Error\InvalidRequest' with message 'Invalid integer: 997.001' in E:\code\apper\application\libraries\Paybrkr\lib\ApiRequestor.php:98 Stack trace: #0 ...
In production, users just see a blank/500 error which I understand is by design. However the error appears nowhere in the prod logs. I would expect under Critical or Error log level. Any special settings required in php.ini for GAE?

Why is this error happening? Class 'FPDF' not found -- typo3-flow

The error happens when warming up caches and is in full:
PHP Fatal error: Class 'FPDF' not found in /home/shop/public_html/releases/20150122171219/Packages/Sites/Mystuff.ModelSite/Classes/Mystuff/ModelSite/Service/InvoiceService.php on line 14
Uncaught Exception
Execution of subprocess failed with exit code 255 without any further
output. (Please check your PHP error log for possible Fatal errors)
More Information
Exception code #1355480641
File /home/shop/public_html/releases/20150122171219/Packages/Framework/TYPO3.Flow/Classes/TYPO3/Flow/Core/Booting/Scripts.php line 531
Exception reference #201504011936306ce58c
I've seen this error before and got around it but can't for the life of me remember how nor can I find the notes I'm sure I made about it. Driving me crazy. What is weird is that the live server gets this error but not my dev server, which is a copy of the live one. The fpdf.php is there.
Thanks

Categories