下記のサイトを参考に、Cakephpで認証コンポーネントを使ったログイン処理を作成中なのですが、エラーが出てしまいます。
https://www.ritolab.com/entry/77
https://qiita.com/yu1ro/items/5a3c81d2e705475669e9
ソース
AppController.php
php
1<?php 2namespace App\Controller; 3 4use Cake\Controller\Controller; 5use Cake\Event\Event; 6 7class AppController extends Controller 8{ 9 10 11 public function initialize() 12 { 13 parent::initialize(); 14 15 $this->loadComponent('RequestHandler', [ 16 'enableBeforeRedirect' => false, 17 ]); 18 $this->loadComponent('Flash'); 19 $this->loadComponent('Auth', [ 20 'loginAction' => [ 21 'controller' => 'Admins', 22 'action' => 'login' 23 ], 24 'loginRedirect' => [ 25 'controller' => 'Admins', 26 'action' => 'index' 27 ], 28 'logoutRedirect' => [ 29 'controller' => 'Admins', 30 'action' => 'login', 31 'home' 32 ], 33 'authenticate' => [ 34 'Form' => [ 35 'fields' => ['username' => 'username', 'password' => 'password'] 36 ] 37 ], 38 ]); 39 } 40 public function beforeFilter(Event $event) 41 { 42 $this->Auth->config('authenticate', [ 43 'Form' => ['userModel' => 'admins'], 44 ]); 45 } 46}
エラー内容
Deprecated (16384): Cake\Controller\Component\AuthComponent::config() is deprecated. Use setConfig()/getConfig() instead. - xxx/src/Controller/AppController.php, line: 80
You can disable deprecation warnings by settingError.errorLevel
toE_ALL & ~E_USER_DEPRECATED
in your config/app.php. [CORE/src/Core/functions.php, line 311]Warning (512): Unable to emit headers. Headers sent in file=xxx/vendor/cakephp/cakephp/src/Error/Debugger.php line=853 [CORE/src/Http/ResponseEmitter.php, line 51]
Warning (2): Cannot modify header information - headers already sent by (output started at xxx/vendor/cakephp/cakephp/src/Error/Debugger.php:853) [CORE/src/Http/ResponseEmitter.php, line 153]
Warning (2): Cannot modify header information - headers already sent by (output started at xxx/vendor/cakephp/cakephp/src/Error/Debugger.php:853) [CORE/src/Http/ResponseEmitter.php, line 185]
Warning (2): Cannot modify header information - headers already sent by (output started at xxx/vendor/cakephp/cakephp/src/Error/Debugger.php:853) [CORE/src/Http/ResponseEmitter.php, line 185]
どのように修正したらよいか教えていただきたいです。
また、 ”$this->loadComponent('Auth'…” の部分をコメントアウトすると上記のエラーは消えるので、この辺りが絡んでいるのではないかと思います。
よろしくお願いします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/04 01:21