New Api App for YII2 Premium Edition

Source: Internet
Author: User
Tags yii

first copy the backend to API:CP in the root directory of the project backend/API-r Copy API Environment CP-A environments/dev/frontend environments/dev/APICP-A environments/prod/frontend environments/prod/API Modification Environments/index.php file after the code (mainly added some API-related code): Copy the Codereturn [    ' Development ' = [        ' Path ' = ' dev ', ' setwritable ' = [            ' Backend/runtime ', ' backend/web/assets ', ' frontend/runtime ', ' frontend/web/assets ', ' Api/runtime ', ' api/web/assets ',        ], ' setexecutable ' = [            ' Yii ',        ], ' setcookievalidationkey ' = [            ' backend/config/main-local.php ', ' frontend/config/main-local.php ', ' api/config/main-local.php ',        ],    ], ' Production ' = [        ' Path ' = ' prod ', ' setwritable ' = [            ' Backend/runtime ', ' backend/web/assets ', ' frontend/runtime ', ' frontend/web/assets ', ' Api/runtime ', ' api/web/assets ',        ], ' setexecutable ' = [            ' Yii ',        ], ' setcookievalidationkey ' = [            ' backend/config/main-local.php ', ' frontend/config/main-local.php ', ' api/config/main-local.php ',        ],    ],]; Copy the code and then execute the initialization command: PHP init then remember to go to common/config/bootstrap.Add the following code to the last line of PHP: Yii:: Setalias (' API ',dirname(dirname(__dir__)) . '/api '); Modify the configuration file API/config/main.PHPreturn [    ' id ' = ' app-api ',// ... ' Controllernamespace ' = ' api\controllers ',] Finally, the API inside the controller and other namespaces have to modify the file. 

New Api App for YII2 Premium Edition

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.