bicf / yii2-security-headers

Component dedicated to the management of all headers security related.
GNU General Public License v2.0
3 stars 2 forks source link

Failed to load #1

Closed alladas closed 5 years ago

alladas commented 5 years ago

Hi @bicf , I gave a try to your component, but it failed. To make it load

I have changed 'on afterPrepare' => ['bicf\securityheaders\components\Response','modulesInit'], to 'on afterPrepare' => ['bicf\securityheaders\components\Response','init'],

But then it failed also with the following errors:

An Error occurred while handling another error: Error: Using $this when not in object context in vendor/yiisoft/yii2/web/Response.php:249 Stack trace:

0 vendor/bicf/yii2-security-headers/src/components/Response.php(71): yii\web\Response::init()

1 [internal function]: bicf\securityheaders\components\Response::init(Object(yii\base\Event))

2 vendor/yiisoft/yii2/base/Component.php(627): call_user_func(Array, Object(yii\base\Event))

3 vendor/yiisoft/yii2/web/Response.php(338): yii\base\Component->trigger('afterPrepare')

4 vendor/yiisoft/yii2/web/ErrorHandler.php(135): yii\web\Response->send()

5 vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(Error))

6 [internal function]: yii\base\ErrorHandler->handleException(Object(Error))

7 {main}

Previous exception: Error: Using $this when not in object context in vendor/yiisoft/yii2/web/Response.php:249 Stack trace:

0 vendor/bicf/yii2-security-headers/src/components/Response.php(71): yii\web\Response::init()

1 [internal function]: bicf\securityheaders\components\Response::init(Object(yii\base\Event))

2 vendor/yiisoft/yii2/base/Component.php(627): call_user_func(Array, Object(yii\base\Event))

3 vendor/yiisoft/yii2/web/Response.php(338): yii\base\Component->trigger('afterPrepare')

4 vendor/yiisoft/yii2/base/Application.php(392): yii\web\Response->send()

5 frontend/web/index.php(22): yii\base\Application->run()

6 {main}

Is this working for you or it is just a matter of documentation? In advance thanks for any hints. EDIT: Tried on Yii2 version 2.0.15.1 and 2.0.19 - Advanced Template PHP 7.2.12

bicf commented 5 years ago

Yep, the Readme was obsolete. I've updated the Readme.md with the correct config.

alladas commented 5 years ago

@bicf , Yes, that was it. Thank you for your reactivity.