我想在 config/app.php 的 'provider' 数组中注册 'authserviceprovider' 提供程序,但是 'provider' 数组不在该文件中,是我的安装有问题,还是我的 laravel 版本有问题?我正在使用 laravel 10 和 php 8.2.12
这是我的 config.app.php 文件
之前在我的项目中,我想创建一个SSO服务器,所以我安装了Auth和Passport包,帮我解决这个问题
<?php
return [
/*
|--------------------------------------------------------------------------
| Application Name
|--------------------------------------------------------------------------
|
| This value is the name of your application, which will be used when the
| framework needs to place the application's name in a notification or
| other UI elements where an application name needs to be displayed.
|
*/
'name' => env('APP_NAME', 'Laravel'),
/*
|--------------------------------------------------------------------------
| Application Environment
|--------------------------------------------------------------------------
|
| This value determines the "environment" your application is currently
| running in. This may determine how you prefer to configure various
| services the application utilizes. Set this in your ".env" file.
|
*/
'env' => env('APP_ENV', 'production'),
/*
|--------------------------------------------------------------------------
| Application Debug Mode
|--------------------------------------------------------------------------
|
| When your application is in debug mode, detailed error messages with
| stack traces will be shown on every error that occurs within your
| application. If disabled, a simple generic error page is shown.
|
*/
'debug' => (bool) env('APP_DEBUG', false),
/*
|--------------------------------------------------------------------------
| Application URL
|--------------------------------------------------------------------------
|
| This URL is used by the console to properly generate URLs when using
| the Artisan command line tool. You should set this to the root of
| the application so that it's available within Artisan commands.
|
*/
'url' => env('APP_URL', 'http://localhost'),
/*
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. The timezone
| is set to "UTC" by default as it is suitable for most use cases.
|
*/
'timezone' => env('APP_TIMEZONE', 'UTC'),
/*
|--------------------------------------------------------------------------
| Application Locale Configuration
|--------------------------------------------------------------------------
|
| The application locale determines the default locale that will be used
| by Laravel's translation / localization methods. This option can be
| set to any locale for which you plan to have translation strings.
|
*/
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'),
/*
|--------------------------------------------------------------------------
| Encryption Key
|--------------------------------------------------------------------------
|
| This key is utilized by Laravel's encryption services and should be set
| to a random, 32 character string to ensure that all encrypted values
| are secure. You should do this prior to deploying the application.
|
*/
'cipher' => 'AES-256-CBC',
'key' => env('APP_KEY'),
'previous_keys' => [
...array_filter(
explode(',', env('APP_PREVIOUS_KEYS', ''))
),
],
/*
|--------------------------------------------------------------------------
| Maintenance Mode Driver
|--------------------------------------------------------------------------
|
| These configuration options determine the driver used to determine and
| manage Laravel's "maintenance mode" status. The "cache" driver will
| allow maintenance mode to be controlled across multiple machines.
|
| Supported drivers: "file", "cache"
|
*/
'maintenance' => [
'driver' => env('APP_MAINTENANCE_DRIVER', 'file'),
'store' => env('APP_MAINTENANCE_STORE', 'database'),
],
];
我希望下次创建 Laravel 项目时也能拥有该数组和 authserviceprovider。或者在这个项目中有一种提供数组的方法
根据您的代码,您使用的是 Laravel 11,而不是 Laravel 10。
在Laravel 11中,所有服务提供者都注册在 bootstrap/providers.php 配置文件。该文件返回一个数组 包含应用程序服务提供者的类名。
当您调用 make:provider Artisan 命令时,Laravel 将 自动将生成的提供程序添加到 bootstrap/providers.php 文件。但是,如果您手动创建了 提供程序类,您应该手动将提供程序类添加到 数组
如果您阅读发行说明
而不是包含五个的默认 Laravel 应用程序结构 服务提供商,Laravel 11 只包含一个 应用服务提供商。先前服务的功能 提供者已经被合并到bootstrap/app.php中,被处理 由框架自动执行,或者可以放置在您的应用程序中 应用服务提供商。
例如,现在默认启用事件发现,很大程度上 无需手动注册事件及其事件 听众。但是,如果您确实需要手动注册事件,您 可以简单地在 AppServiceProvider 中执行此操作。同样,路线模型 您之前可能已注册的绑定或授权门 AuthServiceProvider 也可以注册在 应用服务提供商。