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?
Related
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?
I am trying to implement basic functionality of the Stripe API, I get 500 Internal Server Error for some reason when I require the Stripe.php file that you have to require...When I comment the require out the error goes away but obviously I can not use the API then..
Basic require...shows error in the Modal Log
require_once('/php/Stripe.php');
I checked the server error and it gave me this back
Fatal error: Uncaught exception 'Exception' with message 'Stripe needs the Multibyte String PHP extension.' in /php/Stripe.php:13 Stack trace: #0 /home/stripepost.php(4): require_once() #1 {main} thrown in /php/Stripe.php on line 13
This all comes from just requiring the file..
Is your 'Stripe.php' file really located in '/php' or is it in a folder called 'php' local to your code?
Current code:
require_once('/php/Stripe.php');
I think the problem is this. You probably mean to use something relative to your code base. Like this:
require_once('./php/Stripe.php');
I found out the answer I didn't have the mbstring enabled on my server...whooops
I am using Laravel for a site. I have a page where users can contact me. This sends me an email using the SwiftMailer bundle. It has just been brought to my attention that the following error is seen when trying to send a message
Fatal error: Uncaught exception 'Swift_TransportException'
Exception thrown from here /Applications/MAMP/htdocs/yooies_site/bundles/swiftmailer/library/classes/Swift/Transport/Esmtp/AuthHandler.php on line 176
Code at this location is:
throw new Swift_TransportException(
'Failed to authenticate on SMTP server with username "' .
$this->_username . '" using ' . $count . ' possible authenticators'
);
The cause of the error is not a worry (I found out that I had change my mail password and forgot to change in my sites email config)
The issue I have is that I have Laravel setup to log any exceptions and NOT display them on the main page. I have the following setup in my error.php config file
'detail' => false,
'log' => true,
Why then is my site showing the exception on the page instead of a 500 error?
Full stack trace here (Note I have removed my sites real name and replaced with 'site'
Fatal error: Uncaught exception 'Swift_TransportException'
with message 'Failed to authenticate on SMTP server with username "info+site.com" using 2 possible authenticators'
in /Applications/MAMP/htdocs/site/bundles/swiftmailer/library/classes/Swift/Transport/Esmtp/AuthHandler.php:176
Stack trace:
#0 /Applications/MAMP/htdocs/site/bundles/swiftmailer/library/classes/Swift/Transport/EsmtpTransport.php(307): Swift_Transport_Esmtp_AuthHandler->afterEhlo(Object(Swift_SmtpTransport))
#1 /Applications/MAMP/htdocs/site/bundles/swiftmailer/library/classes/Swift/Transport/AbstractSmtpTransport.php(124): Swift_Transport_EsmtpTransport->_doHeloCommand()
#2 /Applications/MAMP/htdocs/site/bundles/swiftmailer/library/classes/Swift/Mailer.php(79): Swift_Transport_AbstractSmtpTransport->start()
#3 /Applications/MAMP/htdocs/site/application/libraries/personal/mailer.php(55): Swift_Mailer->send(Object(Swift_Message))
#4 /Applications/MAMP/htdocs/site/application/config/error.php(91): Personal\Mai in /Applications/MAMP/htdocs/site/bundles/swiftmailer/library/classes/Swift/Transport/Esmtp/AuthHandler.php on line 176
Laravel version is L3.
Bundle URL here http://bundles.laravel.com/bundle/swiftmailer
Swiftmailer doesn't touch any configuration that's responsible for showing errors. Among the recommendations for production servers is to have display_errors = Off and display_startup_errors = Off, which can be set in php.ini, httpd.conf, .htaccess, .user.ini, etc, or even using ini_set(). You should make sure these directives are correctly set.
I'm not familiar with how Laravel handles exceptions and errors, but it looks like the Swift_TransportException is thrown outside of Laravel's error-handling process. Can you point out where in the flow of the application the exception is thrown? Maybe a stack-trace?
PS: Just a tip: Things like sending emails are better not done during a request at all. You could offload it to some sort of queue, and have another process on the server handle it. You could take a look at Gearman for this.
update
Looking at the stack-trace, it seems Laravel does catch the exception because Log::exception(); is invoked (in application/config/error.php line 91). But the trace doesn't reveal how it got there. Maybe you can run it on a development machine where you have Xdebug installed. Xdebug will give you a more precise stack-trace when the exception is throws, ending with public/index.php (where the request started).
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.
If my mongo database is down, my php application is printing out the plaintext password in the error. How can I prevent this?
Fatal error: Uncaught exception 'MongoCursorException' with message
'couldn't send command' in /ap/db.php:23 Stack trace:
#0 /ap/db.php(23): MongoDB->authenticate('username', 'actual_password')
#1 /ap/index.php(6): Worker->__construct() #2 {main} thrown in /ap/db.php
on line 23
I understand that I can disable php errors, but that is not what I want to do. I want to see an error, but I don't want it to print the password.
In a production application, users should never see an error like "Uncaught exception" or other developer-oriented message. This exposes a lot of information to a potential attacker and confuses your legitimate users. Log the detailed technical message and display a friendly error page to the user.
To disable visible errors and log them instead, edit php.ini:
Set error_log to a valid log path
Set display_errors to Off.
The process to enable friendly errors depends on your web server, but the idea is the same: Set a custom page to be displayed when a 500 error is encountered. In Apache, for example, you set ErrorDocument 500 /path/to/custom/500.html.
EDIT :
OP indicates that this is a development box — either way you should wrap your connection attempt in a try/catch block (which is something you should be doing anyway), and then you can display a 'sanitized' error message:
try {
MongoDB->authenticate('username','password');
} catch (MongoCursorException $e) {
die("Unable to authenticate to database [code: " . $e->getCode() . "]: "
. $e->getMessage());
}