莫名其妙的 Non-static method
今天写接口的时候
无论访问什么接口都出现了这个错误
命名前一天啥都可以访问的
ErrorException (E_DEPRECATED)
Non-static method Illuminate\Routing\Route::middleware() should not be called statically
莫名奇妙的,找了许久的文档和文章还有系统日志,都找不出任何原因。
对比了一下git之前源码版本,发现了api.php出现了以下的use;
use Illuminate\Http\Request;
use Illuminate\Routing\Route;
跟之前的版本对比多出了
use Illuminate\Routing\Route;
没错!就是在写路由的时候不小心引入了这个Route,删除掉即可,暂时先这样,后面找时间了解下为啥子。
查看
config/app.php
文件的aliases
字段可以发现Route
映射的是Illuminate\Support\Facades\Route::class
门面。 门面类中含有以下代码同时在路由服务提供者
Illuminate\Routing\RoutingServiceProvider::class
中,把router
服务定义为Illuminate\Routing\Router::class
你配置路由的时候使用的是
Illuminate\Routing\Route::class
,前者用来定义路由,后者属于被定义的路由