Since PHP 5.5, keyword class can also be used to parse the class name. With Classname::class you can get a string that contains the fully qualified name of the class ClassName. This is especially useful for classes that use namespaces.
$app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class);$app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class);$app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class);
Since the fully qualified name of the class has already been written in this bootstrap/app.php code, why use:: Class syntax?
Reply content:
Since PHP 5.5, keyword class can also be used to parse the class name. With Classname::class you can get a string that contains the fully qualified name of the class ClassName. This is especially useful for classes that use namespaces.
$app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class);$app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class);$app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class);
Since the fully qualified name of the class has already been written in this bootstrap/app.php code, why use:: Class syntax?
People who know the right answer https://www.zhihu.com/questio ...
This is the type App\http\kernel, which is the object type of a class;
This is the class name string Apphttpkernel::class of the class, which is the string.
This question you first understand Laravel's container concept.