我在测试服务器和生产服务器上有一个带有 fortify 的 laravel 8x jetstream 版本。
测试:prj_l8xtest.com 制作:prj_l8xprod.com
我想激活或停用 fortify 提供的一些页面,可以从此处激活或停用它们 -> prj_l8xlocal/config/fortify.php:
.
.
.
.
'features' => [
Features::registration(),
Features::resetPasswords(),
Features::emailVerification(),
Features::updateProfileInformation(),
Features::updatePasswords(),
Features::twoFactorAuthentication([
'confirmPassword' => true,
]),
],
我想根据测试或生产来激活或停用其中一些页面。
我想我可以用 if(){} 来检查有问题的 url(生产或测试),但我不知道如何获取 url。或者还有比我的建议更好的解决方案吗?
配置文件是普通的 PHP,因此您可以在其中编写普通的 PHP 脚本,然后根据需要返回结果。然而问题是,当第一次读取配置时,请求信息没有加载,这就是为什么我建议服务提供商修改启动方法中的配置值。您可以尝试在启动方法中的
AppServiceProvider
中添加以下内容:
public function boot() {
// other boot code
if (app()->environment('production')) {
config([ 'fortify.features' => array_merge(config('fortify.features'), [
// production only features
]);
}
}
请注意,此时并非所有请求信息都可用,因此您可能需要直接访问
$_SERVER
变量来查找您需要的信息。