Q:

How to add custom class in laravel 5.4.10

I am new in laravel.
I am writing following code in the controller method.
include_once(app_path() .'/Classes/Pgp_2fa.php');
$pgp = new Pgp_2fa();

Following errors are shown.

FatalThrowableError in AuthController.php line 146: Class
  'App\Http\Controllers\Pgp_2fa' not found

A:

You have to use the correct namespace for your class. 
If you are not using any namespace, you should add a \ in front of the class to let php know that the class exists in the root namespace. Otherwise php will look in the current namespace which is App\Http\Controllers when you are in a controller.
$pgp = new \Pgp_2fa();

This is not just Laravel behavior but php in general.

