0

I need override some functions of yii\web\ErrorHandler and create child class api\components\ErrorHandler.

Config app in api/config/main.php:

`...
 'errorHandler' => [
   'class' => \api\components\ErrorHandler::class,
 ],
 ...`

Error in nginx log:

FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class api\components\ApiErrorHandler does not exist' in path/yii/vendor/yiisoft/yii2/di/Container.php:415

1
  • 1
    Obviously somewhere in your code there is this call for ApiErrorHandler that does not exist in pointed namespace. Find it and fix it. Commented Jan 12, 2017 at 16:43

1 Answer 1

2

if you're using yii/app-advanced, you need to let yii know where namespace roots are.
add the following line to common/config/bootstrap

Yii::setAlias('@api', dirname(dirname(__DIR__)) . '/api'); // add api alias

otherwise carefully check your folder structure, file and class names

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.