Thursday, 25 November 2021

How do I disable error reporting in Laravel

To disable error reporting in larval production we simply need to set different environment variables.


In your .env file

APP_DEBUG=false

APP_ENV=production


After updating or adding app_debug to false. We need to clear the cache using the artisan command.

php artisan config:clear





Tuesday, 23 November 2021

Laravel Class 'App\Http\Controllers\Config' not found

 


Issue:

Symfony\Component\Debug\Exception\FatalThrowableError Class 'App\Http\Controllers\Config' not found

Possible solution:

When we try to use config() helper function or facade Config::get() in our controller and we forgot to include the namespace of the function.


We only need to include the requried namespace.As like below screenshot.






Monday, 8 November 2021

Laravel Class 'App\Http\Controllers\Input' not found

 In Laravel, the above error occurs because it cannot find the required class in the controller.

 

Sometimes, we use validation, and if validation fails, we need to show all old inputs.

inside form fields when we used to do the following.

For example

// Validation errors.

if ($validator->fails()) {

  return redirect()->back()->withInput(Input::all())->withErrors($validator)->withInput();

}

It will throw the error. 


if we do not include the required namespace.

Laravel csrf token mismatch for ajax post request

Error "CSRF Token Mismatch" commonly occurs if tokens do not match in both sessions and sent , and received requests.CSRF token he...