我正在嘗試使用他們的PHP客戶端https://iflychat.com/installation/php-chat-client與Symfony一起運行iFlyChat,我已經使用composer成功安裝了它。使用Symfony安裝iFlyChat
我創建的代碼的擴展:
<?php
namespace DW\UserBundle\Twig;
use DW\UserBundle\Service\UserService;
use Iflylabs\iFlyChat;
class ChatExtension extends \Twig_Extension
{
/**
* @var UserService
*/
private $userService;
/**
* @var string
*/
private $appId;
/**
* @var string
*/
private $apiKey;
/**
* @param UserService $userService
* @param string $appId
* @param string $apiKey
*/
public function __construct(UserService $userService, string $appId, string $apiKey)
{
$this->userService = $userService;
$this->appId = $appId;
$this->apiKey = $apiKey;
}
/**
* @return array
*/
public function getFunctions()
{
return [
new \Twig_SimpleFunction("chat", [$this, "chat"])
];
}
public function chat()
{
$iflyChat = new iFlyChat($this->appId, $this->apiKey);
echo $iflyChat->getHtmlCode();
}
/**
* @return string
*/
public function getName()
{
return 'chat_extension';
}
}
,但我得到一個錯誤:
Attempted to load class "iFlyChat" from namespace "IFlyLabs". Did you forget a "use" statement for another namespace?
我需要做一些與磁帶自動加載?我一直在尋找registerPrefixes here,但是Symfony3.2不再存在。
它已經有''Iflylabs \\'=>數組($ vendorDir。'/ iflylabs/iflychat-php/lib')' – Jonathan