【问题标题】:Cakedc Users Could not load configuration fileCakedc 用户无法加载配置文件
【发布时间】:2016-06-03 09:14:44
【问题描述】:

我正在使用CakeDC's Users 插件进行身份验证。 我已按照 here 中记录的所有安装步骤进行操作,但出现此错误:

我已经执行了以下步骤:

  1. composer require cakedc/users
  2. composer require league/oauth2-facebook:@stable
  3. composer require league/oauth2-google:@stable
  4. bin/cake migrations migrate -p CakeDC/Users
  5. 在 config/bootstrap.php 中
    Configure::write('Users.config', ['users']);
    Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true ]);
    Configure::write('Users.Social.login', true); //to enable social login
  1. 在你的 src/Controller/AppController.php 中加载组件,然后使用 传递的组件配置来自定义用户插件:

    $this->loadComponent('CakeDC/Users.UsersAuth');
    

更新:我已删除

Configure::write('Users.config', ['users']);

我的引导程序中的这一行,因为我正在使用默认的 users.php 文件,该文件现在存在于插件中。 但我现在收到此错误:

Invalid provider or missing class (League\OAuth2\Client\Provider\LinkedIn)

我可以通过禁用社交登录来摆脱这个错误(这不是我想要做的):

Configure::write('Users.Social.login', false);

禁用社交登录后,我收到此错误:

Error: A route matching "array ( 'plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'login', 'prefix' => false, '_ext' => NULL, )" could not be found.

任何帮助都会挽救我的一天。

【问题讨论】:

  • 尝试从插件内部的 users.php 文件中删除 linkedIn 配置。添加 Configure::write('Users.Social.login', true);在应用程序的 bootstrap.php 文件(不是插件的 bootstrap.php)中启用社交登录模块。

标签: cakephp-3.0 cakedc


【解决方案1】:

@ndm 是对的,第 5 步用于配置,使用 composer 安装时删除以下 2 行修复了迁移步骤之前的错误:

Configure::write('Users.config', ['users']);
Plugin::load('CakeDC/Users', ['routes' => true, 'bootstrap' => true ]);

然后在迁移后重新添加这些行以继续安装。

【讨论】:

    【解决方案2】:

    第 5 步是自定义 - 检查您链接的文档中的标题。所以这实际上不是必需的安装步骤。

    从命名、您遇到的错误和堆栈跟踪(只需检查每个帧中正在执行的操作)应该很容易解决问题 - 设置 Users.config 将用于定义自定义配置文件,您定义的文件不存在(或不可恢复),因此出现错误。

    collection((array)Configure::read('Users.config'))->each(function ($file) {
        Configure::load($file);
    });
    

    https://github.com/CakeDC/users/blob/3.2.0/config/bootstrap.php#L21-L23

    所以要么不要这样做,而是在别处定义配置(在您的 app 配置中或其他任何地方),或者创建缺少的 users.php 配置文件并将您的用户插件配置放在那里。

    另见

    https://github.com/CakeDC/users/.../Configuration.md#overriding-the-default-configuration

    【讨论】:

    • 我没有在我的 config/ 中创建 users.php 文件,因为它已经存在于插件 vendor/cakedc/users/config/users.php 中。所以我刚刚从 bootstrap.php 中删除了该行,但现在错误是:Invalid provider or missing class (League\OAuth2\Client\Provider\LinkedIn)
    • 我没有安装 Linkedin 部分插件,因为我只想要 Facebook 和 Google 身份验证。
    • 我也将社交登录设置为 false,所以这个错误也消失了,但现在它说:错误:路由匹配“数组('插件'=>'CakeDC /用户',' controller' => 'Users', 'action' => 'login', 'prefix' => false, '_ext' => NULL, )" 找不到。
    猜你喜欢
    • 2013-01-27
    • 1970-01-01
    • 1970-01-01
    • 2014-11-25
    • 2015-12-12
    • 2022-06-29
    • 2018-06-21
    • 1970-01-01
    • 2013-12-29
    相关资源
    最近更新 更多