在不知道 Laravel 外观如何工作的情况下,基于我的 PHP 知识,我尝试扩展 Storage 外观以添加一些新功能。
我有这个代码:
class MyStorageFacade extends Facade {
/**
* Get the binding in the IoC container
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'MyStorage'; // the IoC binding.
}
}
启动服务提供商时:
$this->app->bind('MyStorage',function($app){
return new MyStorage($app);
});
门面是:
class MyStorage extends \Illuminate\Support\Facades\Storage{
}
使用时:
use Namespace\MyStorage\MyStorageFacade as MyStorage;
MyStorage::disk('local');
我收到此错误:
Facade.php 第 237 行中的 FatalThrowableError:调用未定义的方法 Namespace\MyStorage\MyStorage::disk()
还尝试扩展MyStorage
表单Illuminate\Filesystem\Filesystem
并以其他方式得到相同的错误:
Macroable.php 第 74 行中的 BadMethodCallException:方法磁盘不存在。