PHP - Laravel error : Symfony\Component\Finder\Exception\DirectoryNotFoundExceptionon my cPanel - php

I mistakenly ran my laravel application on debug mode in my production environment, and it threw an error for me to change App_debug:true to App_debug:false, which I did, ever since then, my site has been throwing an HTTP ERROR 500
"This page isn’t working admin.robyhub.com is currently unable to handle this request.
HTTP ERROR 500"
I then went on to my cpanel terminal and tried to clear the logs on the config file but it gives me the below error.
[thehcerl#premium261 admin.robyhub.com]$ php artisan config:clear
Symfony\Component\Finder\Exception\DirectoryNotFoundException
The "/home/thehcerl/admin.robyhub.com/resources/lang/ha" directory does not exist.
at vendor/symfony/finder/Finder.php:590
586▕ } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? \GLOB_BRACE : 0) | \GLOB_ONLYDIR | \GLOB_NOSORT)) {
587▕ sort($glob);
588▕ $resolvedDirs = array_merge($resolvedDirs, array_map([$this, 'normalizeDir'], $glob));
589▕ } else {
➜ 590▕ throw new DirectoryNotFoundException(sprintf('The "%s" directory does not exist.', $dir));
591▕ }
592▕ }
593▕
594▕ $this->dirs = array_merge($this->dirs, $resolvedDirs);
+2 vendor frames
3 app/Providers/TranslationServiceProvider.php:40
Illuminate\Support\Facades\Facade::__callStatic()
4 app/Providers/TranslationServiceProvider.php:27
App\Providers\TranslationServiceProvider::phpTranslations()
Cpanel Terminal
Ever since I changed debug to false on my .env from my laravel project main directory because the laravel documentation warned me to not use debug mode on a non-local environment. I expected my application would automatically stop receiving the laravel debug config solutions and would run properly.

This is not a very generic error, it's as a result of an error on my part, I created language folders that I did not link to my PHP "translationProvider.php" file, so it invariably gave me that issue.
I was using a purchased template from Envato so I hadn't taken the time to get the full inner working of the backend at the time.
If anyone has a similar error I hope this will guide you not to make the mistakes I made, and meticulously look through your code when making changed or edits.
Thanks, happy coding.

Related

Unable to understand the exception in Prod, while the same functionality works in Dev mode

Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\NotFoundHttpException: "" at /var/www/<projectId>/src/oro/platform/src/Oro/Bundle/FeatureToggleBundle/EventListener/RequestListener.php line 33
And the trace as follows
{/var/www/<projectId>/src/oro/platform/src/Oro/Bundle/FeatureToggleBundle/EventListener/RequestListener.php:33 {▼
Oro\Bundle\FeatureToggleBundle\EventListener\RequestListener->onRequest(GetResponseEvent $event) …
› if ($event->isMasterRequest()) {
› throw new NotFoundHttpException();
› }
}
/var/www/<projectId>/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php:126 {}
And the request for offer functionality, works perfectly fine in Dev but not in Prod.
I have ensured that the files are updated and also made sure there is nothing that is amiss.
Checked DB migrations and ensured that all changes are intact
The fact that the functionality works fine on Dev is strange and When I do <App_URL>/index_dev.php/customer/request/create on the 500 Internal error does not show any error but infact loads the RFQ page perfectly fine and intact.
Any suggestions to debug this error or an understanding of What may be going wrong ?
According to the error message and the stack trace, you have the feature enabled in dev but disabled in a prod environment. Usually, it happens because of the cache.
So the first suggestion is to remove the file cache manually, using rm -rf var/cache/*, and if you are using Redis, flush the redis database as well. The cache:clear command is not always reliable.
You say that the exception is thrown only in prod, but the error stack-trace has wrappers, that must be used only with the debug=true option in the AppKernel. Please, make sure, you haven't customized the index.php file to enable debug, as it is unsecure, and make sure your web-server virtual host is configured to use index.php, not index_dev.php.
The exception comes from the feature toggle bundle. As the last resort, you can check the documentation, on how the feature is implemented, and debug the listener from the trace (src/oro/platform/src/Oro/Bundle/FeatureToggleBundle/EventListener/RequestListener), to see, where the value comes from.

SilverStripe - The website server has not been able to respond to your request

I'm trying to create my first SilverStripe website following this tutorial.
So far I have created my website and configured my .env page.
# DB credentials
SS_DATABASE_CLASS="MySQLDatabase"
SS_DATABASE_SERVER="localhost"
SS_DATABASE_USERNAME="root"
SS_DATABASE_PASSWORD=""
SS_DATABASE_NAME="SS_examples"
SS_ENVIRONMENT_TYPE="dev"
I'm not sure entirely how the database is created when creating a site. I checked my databases and I do not have one for it. I can make one manually but I wasn't sure if I should and list it under SS_DATABASE_NAME, or if it will auto-create the db.
I'm assuming this is why when I visit my local site localhost/SSexample/public I get an error saying "The website server has not been able to respond to your request".
Am I missing a step in setting up the site or should I manually create a db named SS_examples?
on a side note my apache server is set up with xampp and my SilverStripe project is in C:/xamp/htdocs.
Steps I took to create site:
Built site in C:\xampp\htdocs by running: composer create-project silverstripe/installer SSexample
Visited my project by going to localhost/SSexample/public
created .env file as listed above
ERROR LOGS
[2019-12-31 22:29:22] error-log.ERROR: Uncaught Exception SilverStripe\ORM\Connect\DatabaseException: "Couldn't run query: SELECT DISTINCT "SiteConfig"."ClassName", "SiteConfig"."LastEdited", "SiteConfig"."Created", "SiteConfig"."Title", "SiteConfig"."Tagline", "SiteConfig"."CanViewType", "SiteConfig"."CanEditType", "SiteConfig"."CanCreateTopLevelType", "SiteConfig"."ID", CASE WHEN "SiteConfig"."ClassName" IS NOT NULL THEN "SiteConfig"."ClassName" ELSE 'SilverStripe\\SiteConfig\\SiteConfig' END AS "RecordClassName" FROM "SiteConfig" LIMIT 1 Table 'ss_lessons.siteconfig' doesn't exist" at C:\xampp\htdocs\SSlessons\vendor\silverstripe\framework\src\ORM\Connect\DBConnector.php line 64 {"exception":"[object] (SilverStripe\\ORM\\Connect\\DatabaseException(code: 0): Couldn't run query:\n\nSELECT DISTINCT \"SiteConfig\".\"ClassName\", \"SiteConfig\".\"LastEdited\", \"SiteConfig\".\"Created\", \"SiteConfig\".\"Title\", \"SiteConfig\".\"Tagline\", \"SiteConfig\".\"CanViewType\", \"SiteConfig\".\"CanEditType\", \"SiteConfig\".\"CanCreateTopLevelType\", \"SiteConfig\".\"ID\", \n\t\t\tCASE WHEN \"SiteConfig\".\"ClassName\" IS NOT NULL THEN \"SiteConfig\".\"ClassName\"\n\t\t\tELSE 'SilverStripe\\\\SiteConfig\\\\SiteConfig' END AS \"RecordClassName\"\n\r\nFROM \"SiteConfig\"\n\r\nLIMIT 1\n\nTable 'ss_lessons.siteconfig' doesn't exist at C:\\xampp\\htdocs\\SSlessons\\vendor\\silverstripe\\framework\\src\\ORM\\Connect\\DBConnector.php:64)"} []
It seems that the installer at localhost/SSexample/public should allow you to configure your database connection settings (and create the database for you).
Getting The website server has not been able to respond to your request error means that you have a problem with webserver - is it running?
EDIT: The website server has not been able to respond to your request is actually Silverstripe's generic error 500 message.
EDIT2: one has to enable dev environment - by adding SS_ENVIRONMENT_TYPE="dev" to .env file and then access localhost/SSexample/public/dev/build to get database created and populated.

Disable Error Logging In Laravel 4.2 When Environment is Local

I've seen a couple posts around here that tell me how to disable logging. Most of them say I have to comment out a few lines in app/start/global.php, and so I did:
// $logFile = 'laravel.log';
// Log::useDailyFiles(storage_path().'/logs/'.$logFile);
App::error(function(Exception $exception, $code){
// Log::error($exception);
});
My concern is that information still gets written to the log file, say when I navigate to a route that doesn't exist. I've also tried changing when the information is written to the log, for example:
if(App::environment() == "local"){
Log::info("Error Ignored. Environment: Local");
} else {
Log::error($exception);
}
But this doesn't seem to affect anything at all. If I get an error, it still logs the full error, and I know my environment is local by running php artisan env.
Lastly, I don't want to turn 'debug' => false, as I would never be able to see the errors.
After any config changes, it's usually a good idea to run the following commands:
php artisan optimize & php artisan cache:clear

laravel 5 show blank page on server error (and no laravel log), running with hhvm and nginx

I followed Fideloper post about running laravel with hhvm, step by step. There are two projects hosted on my server, one is my blog which is based on wardrobe (laravel 4.1), and another project with laravel 5.
My blog has no issue with server errors and laravel log file; But the other project cannot create log files, and it won't show error page because of that.
I double checked storage folder permission. It is 777.
When I run php artisan serve (native php, not hhvm) and browse to it, the error page showed up, and log file was created. So something is wrong with hhvm I think.
How can I fix blank page, when running laravel 5 with hhvm, and an error occurred? How can I bring back the error page (or whoops page)
P.S. I have read related question like this and still have the problem.
P.S.S. If any information needed ask me and I will update the question.
I suffered the same problem when I installed Laravel Homestead with HHVM. If you enter some random junk like sdfkjl into your routes file you'll get a blank page (however, if add a semi-colon sdfkjl; you get error output). The errors are being logged at /var/log/hhvm/error.log but they don't go to the browser, instead you just get a blank page. It appears this is intentional behavior for HHVM. It also appears Laravel tries to handle these but doesn't catch some of the fatals sent by HHVM. Thanks to clues from this github issue I decided to make some slight changes to Laravel's Foundation\Bootstrap\HandleExceptions.php to see if I could get it to catch all of these fatals:
First, update your /etc/hhvm/php.ini and add these settings:
hhvm.server.implicit_flush = true
hhvm.error_handling.call_user_handler_on_fatals = true
Before modifying a package source, let's remove the vendor\compiled.php with this artisan command:
$ php artisan clear-compiled
And let's set the environment sessons to array:
in your .env
SESSION_DRIVER=array
(You may also need to clear all the random-looking session files in storage/framework/sessions)
Now any changes we make to the Laravel package source will immediately reflect. Let's update a few things in the HandleExceptions class:
in vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php
// **** Add this to hold fatal error
protected static $fatalError = null;
...
public function handleError($level, $message, $file = '', $line = 0, $context = array())
{
// **** Add this, loads fatal error
if ($level & (1 << 24)) {
self::$fatalError = array(
'message' => $message,
'type' => $level,
'file' => $file,
'line' => $line
);
}
if (error_reporting() & $level)
{
throw new ErrorException($message, 0, $level, $file, $line);
}
}
...
// *** Update this function so it can handle the fatal
public function handleShutdown()
{
$error = error_get_last();
if(self::$fatalError){
$error = self::$fatalError;
}
if ( ! is_null($error) && $this->isFatal($error['type']))
{
$this->handleException($this->fatalExceptionFromError($error, 0));
}
}
...
protected function isFatal($type)
{
// *** Add type 16777217 that HVVM returns for fatal
return in_array($type, [16777217, E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR, E_PARSE]);
}
...
Now type the random junk (no semi-colon) in your routes folder and you'll see the fatal display. I have now reported this issue to Taylor on the Laravel github. If you are in Lumen, I've got a solution here that will work until Lumen gets fixed as well.
I also got the same issue. Give 755 permission to entire laravel project it's work for me
anyway you can check hhvm error log, run
$tail -n 50 -f /var/log/hhvm/error.log

How to debug Laravel 5 projects?

I ran command
php artisan optimize
and changed debug settings in app.php file to be
'debug' => 'true',
and added 'everyone' to have full access over 'storage' folder. I don't know what else I can do to let debugger work in my Laravel 5 project.
I'm stuck with 'Whoops, looks like something went wrong' message.
Any Ideas??
The debug => true will just show you the full error stack when you hit an error with your app. It doesn't give metrics and statistics. If you are looking for that kind of information check out the article here:
https://laravel-news.com/2015/02/laravel-debugbar/
The error you are receiving is a general error, likely server-side configuration. Without any information on your setup it will be pretty hard to determine what your issue is. Based upon your question and comments to others responses I have a couple of things for you.
You stated "I don't know what else I can do to let debugger work in my Laravel 5 project". Laravel 5 doesn't have a native debugger any more which I imagine is why your page just shows "Whoops, looks like something went wrong". Your statement would indicate that you have a debugger, so which are you trying to use, or was that statement incorrect?
You stated that you changed the debug settings the app.php file. Is there a reason why you changed this in app.php? The debug setting by default is 'debug' => env('APP_DEBUG') which is sufficient in most cases. You should have a .env file in the root of your project (created automatically if you did a composer create-project, if not you need to copy .env.example to .env on your own). The .env file will enable debug for you as there is a line that states APP_DEBUG=true.
Jesse Schutt gave great information in his response above (which I recommend upvoting), including a link to a debug bar that is compatible with L5. Yet again you are stating that you are satisfied with your error stack which implies that you actually have one. If you were satisfied with it, you would have no need to have posted here as you would already have more information on your error. If you are assuming that the filp/whoops is in l5 still and that's what you want you'll have to re-enable it. Follow the instructions at http://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5

Categories