我想給Yii2用戶數據的第三方PHP應用程序訪問(HumHub),並嘗試這樣的:如何第三方應用程序訪問Yii2(HumHub)
function getUserId() {
require_once('../protected/vendor/yiisoft/yii2/Yii.php');
$yiiConfig = require('../protected/config/common.php');
(new humhub\components\Application($yiiConfig));
$user = Yii::$app->user->identity;
return $user;
}
這是行不通的。直到new humhub\components\Application($yiiConfig)
之前沒有任何錯誤,但第三方應用程序中斷並沒有拋出任何錯誤,並且該函數不返回任何內容。
我確實發現this solution哪些不起作用。
是否有理由這不起作用或有沒有替代解決方案來正確獲取Yii2用戶數據?
你讀[**這個官方**](http://www.yiiframework.com/doc-2.0/guide-tutorial-yii-integration.html#使用-yii-in-others)文件? – SaidbakR