Laravel 外观类错误 - 不应静态调用非静态方法


Laravel Facade class error - Non-static method should not be called statically

这是我得到的错误:

Non-static method Tester'Test::echoString() should not be called statically, assuming $this from incompatible context

以下是我添加到应用程序.php的内容:

服务提供商:

"Tester'TestServiceProvider"

和别名:

"Test" =>  "Tester'Test"

这是我的主要类。 命名:test.library.php:

namespace Tester;
class Test 
{
    function echoString()
    {
        echo "This is a text string";
    }
    function printer($input)
    {
        $this->echoString();
        echo " $input";
    }
}

这是我的test.facade.php文件:

class Test extends 'Illuminate'Support'Facades'Facade
{
    protected static function getFacadeAccessor() { return 'Test'; }
}

下面是 test.serviceprovider.php 类:

use Illuminate'Support'ServiceProvider;
class TestServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->bind('Test', function()
        {
            return new 'Tester'Test(); // Name of your class, be sure to include the namespace if you are using one.
        });
    }
}
我认为

这是因为您有一个名为Test的类和一个名为Test的外观。这是命名空间上的冲突。

.. 可能将 Test(外观)重命名为 TestFacade,然后将别名设置为 "Test" => "Tester'TestFacade"