From PHP5.5, the keyword class can also be used for parsing class names. You can use ClassName: class to obtain a string that contains the fully qualified name of the class ClassName. This is especially useful for classes that use namespaces. {Code...} bootstrapapp. php code...
Since PHP 5.5, the keyword class can also be used for parsing class names. You can use ClassName: class to obtain 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 been written in the bootstrap/app. php code, why should I use the: class syntax?
Reply content:
Since PHP 5.5, the keyword class can also be used for parsing class names. You can use ClassName: class to obtain 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 been written in the bootstrap/app. php code, why should I use the: class syntax?
I know someone gave the correct answer to 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, which is a string.
You should first understand the concept of Laravel containers.