Series: Yii2 Advanced in Action Series: RESTful API + RPC Services + Internationalization + Logging & Testing

新建 api 目录、配置和环境、测试、Vagrant 等的支持。 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), support for creating new API directories, configuration and environment, testing, vagrant, etc.

浏览量: 48 1. Create a new warehouse, shuijingwan/yii2-app-advanced, as shown in Figure 1 Yii 2 advanced project template, the template includes four layers: interface (the API to implement the RESTful style web service service),...

0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), implement model hierarchy: data layer, logic layer, clarify common directory, application, module inheritance, reference relationship

浏览量: 52 1. Definition and specification: Define: (1) Data layer: Models is used to define automatic verification and automatic completion and data access interfaces related to data; (2) Logical layer: Logics is used to...

在 Postman 中,GET http://api.github-shuijingwan-yii2-app-advanced.localhost/v1/users ,200响应,message为简体中文 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), implement RESTful web service, support internationalization (drivingly set the target language, default to simplified Chinese)

浏览量: 51 1. RESTful web service, it is recommended to implement based on a separate interface application, at this time, it is implemented based on the API application 2. Create a new directory: \api\rests,...

运行测试,获取详细的输出,可看到一步一步的行为报告,符合预期 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), prepare some examples of automated tests (API tests) for user-related operations in the tests directory of the API to ensure that the application will not affect existing functions when changing or adding new functions

浏览量: 54 1. Delete the controller \API\Controllers\SiteController.php, delete the model \api\models\contactform.php, \api\models\loginform.php, \api\models\PasswordResetRequ estform.php, \api\models\resetpasswordform.php, \api\models\signupform.php, delete the directory (view related) \api\views, \api\assets, \api\web\css 2. Delete the relevant files of the test (unit test,...

在 Postman 中,GET http://api.github-shuijingwan-yii2-app-advanced.localhost/v1/logs?filter[level]=4&filter[category][like]=api\behaviors\RequestLogBehavior&filter[prefix][like]=app-api&filter[log_time][gte]=1528090828&filter[log_time][lte]=1529564924.6648 ,200响应,空数组已经被自动转换为空对象,以保证字段格式的统一,GET http://api.github-shuijingwan-yii2-app-advanced.localhost/v1/logs/3 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), adjust the default character set to: utf8mb4, the adjustment of the interface response format, the empty array is automatically converted to empty objects, and the request log message is collected in the interface application (1 request corresponds to 1 log message) to the database, and the corresponding interface to implement the log function: log list (set data filter to enable filter processing), log details

浏览量: 13 1. Set the default collation of the database as: utf8mb4_unicode_ci, as shown in Figure 1 2. Modify the default character set for database connections: utf8mb4, edit the configuration file in the development...

在开发环境中,执行数据库迁移命令失败:1071 Specified key was too long; max key length is 767 bytes 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), adjust the default character set to: utf8mb4, the adjustment of the interface response format, the empty array is automatically converted to empty objects, and the request log message is collected in the interface application (1 request corresponds to 1 log message) to the database, and the corresponding interface to implement the log function: log list (set data filter to enable filter processing), log details (2)

浏览量: 42 1. In the development environment, the execution of the database migration command fails: 1071 Specified key was too long; Max key length is 767 bytes, as shown in Figure 17 2. Run...

浏览 user 表数据,status、updated_at 已经更新 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), realize the soft deletion of ActiveRecord, generate ActiveQuery, and customize the query class

浏览量: 16 1. Based on yii2tech\ar\SoftDelete\SoftDeleteBehavior, the soft deletion of ActiveRecord is realized, and the URL is opened:https://github.com/yiisoft/yii2/blob/master/docs/guide-zh-CN/concept-behaviors.md, as shown in Figure 1 2. Install the ActiveRecord extension of Yii2, use the self-update command...

执行数据库迁移命令,查看数据库表 user 结构,符合预期 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), realize the soft deletion of ActiveRecord, generate ActiveQuery, and customize the query class (2)

浏览量: 21 1. In Postman, posthttp://api.github-shuijingwan-yii2-app-advanced.localhost/v1/users201 response, the status value is 1 by default 2. In Postman, deletehttp://api.github-shuijingwan-yii2-app-advanced.localhost/v1/users/1, 200 responses 3. In Postman, posthttp://api.github-shuijingwan-yii2-app-advanced.localhost/v1/users,422 response, not as expected, expected to be 201 response, because...

在 Postman 中 POST 请求,http://api.github-shuijingwan-yii2-app-advanced.localhost/v1/users ,输入格式:application/json 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new interface application (implement RESTful-style web service services. API), application/x-www-form-urlencoded and multipart/form-data input formats, default support, new application/json input format support

浏览量: 13 1. The API can distinguish application/x-www-form-urlencoded and multipart/form-data input formats by default, and view \api\config\main.php, request Configuration of application components 2. POST request in Postman,http://api.github-shuijingwan-yii2-app-advanced.localhost/v1/users, the input format: application/x-www-form-urlencoded, as shown in...

打开 Windows PowerShell,执行 init 命令并选择 dev 作为环境,api应用所需环境配置文件自动生成 0

Based on yiisoft/yii2-app-advanced, create a new repository yii2-app-advanced on github, and create a new remote procedure call application (implement hprose 2.0 for PHP’s RPC server), support for creating new RPC directories, configuration and environment, testing, Vagrant, etc.

浏览量: 15 1. Implement the corresponding RESTful-style web service API of the page in the API directory, and then adjust it to the RPC client 2. After all the corresponding APIs of the page...