在Laravel 5.3中调用SEOStats实例时找不到类'SEOstats \ SEOstats' [英] Class 'SEOstats\SEOstats' not found when calling SEOStats instances in laravel 5.3

查看:102
本文介绍了在Laravel 5.3中调用SEOStats实例时找不到类'SEOstats \ SEOstats'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在laravel中使用SEOstats php软件包,我已经使用composer安装了它,然后在我的控制器中按如下方式使用它:

I am trying to use SEOstats php package in laravel, I've installed it using composer and then in my controller I have used it like below :

use SEOstats\Services as SEOstats;

class ReportageController extends Controller
{
 public function store(Request $request)
    {

        $url = 'http://www.google.com/';

        // Create a new SEOstats instance.
        $seostats = new \SEOstats\SEOstats;

        // Bind the URL to the current SEOstats instance.
        if ($seostats->setUrl($url)) {

            dd( SEOstats\Alexa::getGlobalRank());
        }
   }
}

问题是我收到此错误消息:

The problem is I'm getting this error message :

Class 'SEOstats\SEOstats' not found

我已将名称空间更改为不同的类型,但仍然出现此错误. 关于如何使它在laravel 5.3中起作用的任何建议

I've changed namespaces to different types but still getting this error. Any suggestion how to make it work in laravel 5.3

推荐答案

由于已将别名指定为SEOstats,因此必须使用别名

Since you have given alias as SEOstats then you have to use alias

use SEOstats\Services as SEOstats;

class ReportageController extends Controller
{
 public function store(Request $request)
    {

        $url = 'http://www.google.com/';

        // Create a new SEOstats instance.
        $seostats = new SEOstats;

        // Bind the URL to the current SEOstats instance.
        if ($seostats->setUrl($url)) {

            dd( SEOstats::getGlobalRank());
        }
   }
}

这篇关于在Laravel 5.3中调用SEOStats实例时找不到类'SEOstats \ SEOstats'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆