在symfony控制器中使用库的名称空间

我的控制器中有以下代码,基本上是尝试使用通过作曲家安装的this

use Symfony\Component\HttpFoundation\Response;
require __DIR__.'/../../vendor/autoload.php';

class MainController
{

    public function number()
    {

        $username = 'someusername';
        $password = 'somepassword';
        $debug = true;
        $truncatedDebug = false;

        $ig = new \InstagramAPI\Instagram($debug,$truncatedDebug);


        $number = random_int(0,100);

        return new Response(
            '<html><body>Lucky number: '.$number.'</body></html>'
        );
    }
}

但是它给了我以下

Attempted to load class "Instagram" from namespace "InstagramAPI".
Did you forget a "use" statement for another namespace?

我尝试添加使用命名空间Instagram,但没有成功

fjbjj 回答:在symfony控制器中使用库的名称空间

根据https://github.com/mgp25/Instagram-API/blob/master/README.md,命名空间称为InstagramAPI

尝试new \InstagramAPI\Instagram($debug,$truncatedDebug);

本文链接:https://www.f2er.com/3136760.html

大家都在问