2017-12-20 7 views
0

私はちょっとCakephp(3.5)の初心者です。私は現在いくつかのサブディレクトリを含む最初のプラグイン(Example)を作ろうとしています。その1つはUserManagerディレクトリであり、認証のあるユーザーMVC標準スーツが含まれています。CakePhp 3プラグイン認証アダプタが見つかりません

私は社会的なログインと他のstuffsを追加したいのでdocsで説明したように、私は私自身の認証コンポーネントを作成しました:

plugins/Example/UserManager/src/Controller/AppController.php

<?php 

namespace Example\UserManager\Controller; 

use App\Controller\AppController as BaseController; 

class AppController extends BaseController 
{ 
    public function initialize() 
    { 
     parent::initialize(); 
     $this->loadComponent('Auth', [ 
      'authenticate' => [ 
       'Example/UserManager.Example' => [ 
        'fields' => ['username' => 'email', 'password' => 'pass'], 
        'userModel' => 'Users', 
       ], 
      ], 
     ]); 
    } 
} 

<?php 

namespace App\Auth; 

use Cake\Auth\BaseAuthenticate; 
use Cake\Http\ServerRequest; 
use Cake\Http\Response; 

class ExampleAuthenticate extends BaseAuthenticate 
{ 
    // The same as Form authentication, since I'm testing 
} 

を問題があります私は認証コンポーネントがExampleAuthenticateクラスを見つけることができません。私はすでに

  • Example
  • ExampleAuthenticate
  • UserManager.Example
  • Example/UserManager.Example
  • Example\UserManager.Example
  • Example/UserManager.ExampleAuthenticate
  • Example\UserManager.ExampleAuthenticate
  • のような authenticate設定のparamを設定することで、試してみました

が、http://localhost/Project/example/user-manager/usersを訪れたとき、私は常にエラーAuthentication adapter "..." was not found.を得る:(

を誰もが、私は失われるかもしれないものの任意の手掛かりを持っていますか?

+0

私は深いプラグインのパスをサポートしていないと思います。 'plugins/Example'や' plugins/UserManager'のパスを使うべきです – kicaj

+0

これは奇妙なことですが、これを試してみると、私は全く新しいミニマリストプロジェクトを作成しましたが、あなたの提案ではできません。カスタム認証の実装について、ドキュメントには記載されていないことはありますか? – Warren

+0

ところで、 'authenticate'パラメータを' Form'に変更すると、すべてが魅力のようになります – Warren

答えて

0

問題がphp機能class_exists(...)は、カスタム認証クラスを認識しなかったので、もう少し掘り後、私は、ドキュメントに示されている名前空間が唯一のアプリケーション環境で定義されたカスタム認証ファイルのために働くことに気づいたが、ということでしたプラグイン1(愚かな私)ではありません。

namespace App\Auth;namespace Example\UserManager\Auth;ExampleAuthenticate.phpに変更しました。これは魅力的に機能しました。関数class_exists('Example\\UserManager\\Auth\\ExampleAuthenticate')trueを返し、authenticateコンフィグパラメータではExample/UserManager.Exampleと定義するとすべてが正常に機能します。

関連する問題