For example - this function uses a facade:

File::get('path/to/file.txt');

事实证明,实际提供File::get的底层类是Illuminate\Filesystem\Filesystem

我查看了Laravel 4.2文档——这是我使用的版本——以及api参考,但我找不到任何东西可以向不知道如何找到facade的"真实"类的人解释.

tutorial on Laravel facades条给出了一种做这件事的方法,包括

  • 寻找File
  • looking to see that it extends class Facade
  • 通过Facade#__callstatic()方法跟踪代码
  • getFacadeAccessor()返回字符串files时跟踪__callstatic()resolveFacadeInstance()的行为
  • 等等等等
  • ... too long / many steps to post

This is a good demonstration of whats going on, but I wouldn't want to do this regularly.

My question is, knowing that the "facaded classes" you use in your app dont necessarily have a the same name or some convention to help you search the filesystem, how can someone - who doesn't know in advance what the underlying class is - find the underlying class for a laravel facade?

推荐答案

这是一个很好的资源:https://laravel.com/docs/facades#facade-class-reference个以外的资源,请确保为您正在使用的任何编辑器安装某种类型的智能感知(IntelliSense)插件.它们中的大多数允许您在按住Ctrl键的同时右键单击某个类/方法,然后转到定义.

Laravel相关问答推荐

Laravel Livewire与自定义JS有关的多姆问题

在Laravel Livewire中,如果一个输入基于另一个唯一的字段是唯一的,如何判断验证?

为什么删除查询执行 Laravel

如何在 Laravel 中将 Select 选项表单插入数据库

在 Laravel 中清除 Routes&config:cache 后未定义的常量

如何在 Laravel 5 中添加我自己的自定义类?

为什么 laravel 模型会重复一组数据以及如何(如果可能)只有一组数据?

laravel 关系集合上的自定义排序

Laravel 5.6 - 如何在 api 控制器中获取 auth()->user() 或 $response->user()?

实施 Payum/Laravel 定期付款

Laravel 合集日期比较

在 Laravel Blade 中转义 vue.js 数据绑定语法?

设置 Laravel 5.4 以使用 React

Laravel lockforupdate(悲观锁)

Laravel Eloquent:计算总价的最佳方法

Laravel 同步错误

在 laravel 6.0 中未定义命令ui

调用未定义的方法 Illuminate\Routing\Route::get()

如何在 laravel 4 中删除文件

Laravel 表:只能有一个自动列,并且必须定义为键