Solve the compatibility problem after upgrading Yii2.0.9 and HProse for PHP 2.0 through Composer
1. The basic implementation of RPC based on HPROSE for PHP 1.5.6 and Yii2.0.7, please refer to the website:https://www.shuijingwanwq.com/2016/03/24/953/
2. Upgrade yii2 through composer and execute the command:composer update, as shown in Figure 1:
3. Open the URL:http://trade.service.ygt.cm/area/get-area-mobile, the error is reported, as shown in Figure 2:
PHP warning – Yii\Base\ErrorException
include(e:\wwwroot\service.ygt.cm\vendor\hprose\hprose\src\hprose\yii\server.php): Failed to open Stream: No such file or directory
4. Analyze the reasons, after the upgrade is found, when submitting SVN, e:\wwwroot\service.ygt.cm\vendor\hprose\hprose\src\hprose\yii Already missing, as shown in Figure 3:
5. The source code screenshot of e:\wwwroot\service.ygt.cm\trade\controllers\hprosecontroller.php, the referenced class file no longer exists, and naturally reports an error, as shown in Figure 4:
6. Open the URL:https://github.com/hprose/hprose-php/wiki/%E5%AE%89%E8%A3%85, edit e:\wwwroot\service.ygt.cm\composer.json, as shown in Figure 5:
“require”: {
“hprose/hprose-yii”: “dev-master”
}
7. Execute the command: composer update in Windows PowerShell, as shown in Figure 6:
After installing yiisoft/yii, it can be ignored for the time being, it is recommended to delete it;
8. Open the URL:http://trade.service.ygt.cm/area/get-area-mobile, the error is reported, as shown in Figure 7:
Unknown Property – Yii\Base\UnknownPropertyException
Getting Unknown Property: Yii\Web\Request::Session
9. Edit E:\wwwroot\service.ygt.cm\vendor\hprose\hprose-yii\src\hprose\yii\service.php, as shown in Figure 8:
// $context->session = $request->session;
$context->session = \yii::$app->Session;
10. Open the URL:http://trade.service.ygt.cm/area/get-area-mobile, as shown in Figure 9:
11. Client calls, errors, as shown in Figure 10:
hprose\future object ([state]=> 1[value]=> hprose\future object ([state]=> 0[value]=>[reason]=>[subscribers:Hprose\Future:private]=> array ( ) )[reason]=>[subscribers:Hprose\Future:private]=> array ( ) )
12. According to the prompts in Figure 6, install the PECL extension of HProse for PHP, and after installing it, it can effectively improve the performance of HPROSE. Open URL:https://github.com/hprose/hprose-php/wiki/hprose-%E7%9A%84-pecl-%E6%89%A9%E5%B1%95, as shown in Figure 11:13. After analysis, version 2.0, the client call, the default is asynchronous, if you need to call synchronously, then $async = False, as shown in Figure 12:
14. Run the client call, which is in line with expectations, as shown in Figure 13:









![客户端调用,出错:Hprose\Future Object ( [state] => 1 [value] => Hprose\Future Object ( [state] => 0 [value] => [reason] => [subscribers:Hprose\Future:private] => Array ( ) ) [reason] => [subscribers:Hprose\Future:private] => Array ( ) )](https://www.shuijingwanwq.com/wp-content/uploads/2016/07/10-3.png)


