laravel5.8 源码分析(1) Route

https://learnku.com/docs/laravel/5.8

源码路径 vendorlaravelframeworksrcIlluminateRoutingRouter.php

搜索 public function   #各种方法不说了
https://learnku.com/docs/laravel/5.8/routing/3890 官方文档

  

 源码路径 vendorlaravelframeworksrcIlluminateRoutingRouter.php

protected $allowedAttributes = [
        'as', 'domain', 'middleware', 'name', 'namespace', 'prefix', 'where',
    ];


//以上方法的属性的调用
public function __call($method, $parameters)
{
if (in_array($method, $this->passthru)) {
return $this->registerRoute($method, ...$parameters);
}

if (in_array($method, $this->allowedAttributes)) {
if ($method === 'middleware') {
return $this->attribute($method, is_array($parameters[0]) ? $parameters[0] : $parameters);
}

return $this->attribute($method, $parameters[0]);
}

throw new BadMethodCallException(sprintf(
'Method %s::%s does not exist.', static::class, $method
));
}

  

原文地址:https://www.cnblogs.com/cbugs/p/11242254.html