Solve Yii2 Class Yii/web/jsonparser does not exist, reflectionexception problem

Source: Internet
Author: User
Tags yii

When you recently debugged the RESTful API sample, the following error occurred:

1 {2"Name": "Exception",3"Message": "Class Yii/web/jsonparser does not exist",4"Code":-1,5"Type": "Reflectionexception",6"File": "/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/di/container.php",7"Line": 426,8"Stack-trace": [9"#0/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/di/container.php (426): ReflectionClass->__ Construct (' Yii/web/jsonpar ... ') ",Ten"#1/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/di/container.php (364): yii\\di\\Container-> Getdependencies (' Yii/web/jsonpar ... ') ", One"#2/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/di/container.php (156): yii\\di\\Container-> Build (' Yii/web/jsonpar ... ', array, array) ", A"#3/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/baseyii.php (345): Yii\\di\\container->get (' Yii /web/jsonpar ... ', Array) ', -"#4/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/web/request.php (531): Yii\\BaseYii::createObject ( ' Yii/web/jsonpar ... '), -"#5/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/rest/createaction.php (Wuyi): yii\\web\\Request-> Getbodyparams () ", the"#6 [internal function]: Yii\\rest\\createaction->run ()", -"#7/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/base/action.php (94): Call_user_func_array (Array, Array) ", -"#8/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/base/controller.php (157): yii\\base\\Action-> Runwithparams (Array) ", -"#9/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/base/module.php (528): yii\\base\\Controller-> Runaction (' Create ', Array) ', +"#10/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/web/application.php (103): yii\\base\\Module-> Runaction (' deptinfo/create ', Array) ", -"#11/users/desktop/workspaces/php/yii2-ims/vendor/yiisoft/yii2/base/application.php (386): yii\\web\\ Application->handlerequest (Object (yii\\web\\request)) ", +"#12/users/desktop/workspaces/php/yii2-ims/api/web/index.php (): Yii\\base\\application->run ()", A"#13 {main}" at     ] -}

Actually, this is oneself to dig a pit for oneself, result put oneself to sink in, the following is the code of the configuration file:

' Request ' = [            ' class ' = ' yii\web\request ',            ' parsers                ' and ' = ' Application/json ' = = ' Yii/web/jsonparser ',            ],        ],

The problem is that the configuration will be "Yii/web/jsonparser" wrong, the correct is "Yii\web\jsonparser", the namespace should be inverted slash "\" split, seemingly small problems, the results of debugging for a long time to find the reason, So when writing code configuration must be careful, so as not to be misled by themselves, wasting precious time.

Solve Yii2 Class Yii/web/jsonparser does not exist, reflectionexception problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.