Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Symfony安装iFlyChat_Php_Symfony - Fatal编程技术网

Php 使用Symfony安装iFlyChat

Php 使用Symfony安装iFlyChat,php,symfony,Php,Symfony,我正在尝试使用他们的PHP客户端使用Symfony运行iFlyChat,我已使用composer成功安装了该客户端 我已经为代码创建了一个扩展: <?php namespace DW\UserBundle\Twig; use DW\UserBundle\Service\UserService; use Iflylabs\iFlyChat; class ChatExtension extends \Twig_Extension { /** * @var UserSer

我正在尝试使用他们的PHP客户端使用Symfony运行iFlyChat,我已使用composer成功安装了该客户端

我已经为代码创建了一个扩展:

<?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';
    }
}

请查看
供应商/composer/autoload_psr4.php
,以确保为IflyChat生成自动加载命名空间

如果没有,您可以执行:

composer转储自动加载


强制composer为依赖项重新生成自动加载。

这是因为文件名与类名不匹配,当类为
iflychat
时,它作为
iflychat.php
安装。将文件重命名为
iFlyChat.php
有效。

它已经存在
'Iflylabs\\\'=>数组($vendorDir./Iflylabs/iFlyChat php/lib')