I am developing an application using anuglarJs
on client side and Lumen
in server side for REST API's. My .env
configuration given below,
APP_ENV=local
APP_DEBUG=TRUE
APP_KEY=XrPbyRlU5p0szSw5MrAQWwWim8C0MXjT
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=kainfo
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=file
SESSION_DRIVER=file
And enabled Dotenv::load(__DIR__.'/../');
in bootstrap/app.php
My problem is,sometimes Lumen
throws 500 exception and working well on next refresh request.
The Error log is ,
[2015-06-06 07:51:41] lumen.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge'' in C:\xampp\htdocs\Study\kasrodinfo\web\vendor\illuminate\database\Connectors\Connector.php:47
You need to change the database,username,password in \vendor\laravel\lumen-framework\config\database.php file
Also affected by this, here is what we have found on this issue:
We were using Apache 2.4 with the Event MPM and a thread-safe build of PHP 7. This caused the env() method to not respond reliably - it could give you the right variable at one point in the code, then just a few rows down it would return something else. (Like the default variable which trevorg was experiencing.)
We switched to using the prefork MPM and the problems vanished instantly.
Yes, prefork sucks in terms of speed when compared to another MPM, but it seems there is some issue with the event MPM and environmental variables in Apache, PHP and/or Laravel/Lumen.