Laravel app() 中存在包别名,但仍然给出 class 未找到

Laravel package alias present in app() but still gives class not found

我可以在应用别名数组中看到我的别名:

    dd(app()); // ... "Me\Package\Facades\PHPFile" => "PHPFile"

使用相同的全名有效

    dd(
        \Me\Package\Facades\PHPFile::load('app/User.php')
    );

但尝试使用已注册的别名:

    dd(
        \PHPFile::load('app/User.php')
    );
    // Error: Class 'PHPFile' not found

尽管它是在 app() 注册的!有什么想法吗?

在我的包裹里composer.json:

"extra": {
    "laravel": {
        "dont-discover": [],
        "providers": [
            "Me\Package\MyServiceProvider"
        ],
        "aliases": {
            "PHPFile": "Me\Package\Facades\PHPFile"
        }            
    }
},

还尝试在我的服务提供商注册方法中添加:

$this->app->alias('PHPFile','Me\Package\Facades\PHPFile');

宿主应用程序composer.json

添加

"repositories": [
    {
        "type": "path",
        "url": "/full/path/to/packages/Me/Package"
    }
],

然后用composer require "me/package @dev"

安装

感谢@lagbox 指出我在评论中的错误