Laravel - Response:: 或 response() - 哪个更好
Laravel - Response:: or response() - which one is better
我只是好奇 Laravel 5.1 中的 Facade 和服务容器绑定功能,假设 Reponse::json()
和 response()->json()
是相同的。但是有什么理由说其中一个比另一个更好吗?
Laravel 的文档中已经说明
Facades provide a "static" interface to classes that are available in
the application's service container. Laravel ships with many facades,
and you have probably been using them without even knowing it! Laravel
"facades" serve as "static proxies" to underlying classes in the
service container, providing the benefit of a terse, expressive syntax
while maintaining more testability and flexibility than traditional
static methods.
Laravel 的创建者 this article 也会帮助您。
我只是好奇 Laravel 5.1 中的 Facade 和服务容器绑定功能,假设 Reponse::json()
和 response()->json()
是相同的。但是有什么理由说其中一个比另一个更好吗?
Laravel 的文档中已经说明
Facades provide a "static" interface to classes that are available in the application's service container. Laravel ships with many facades, and you have probably been using them without even knowing it! Laravel "facades" serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.
Laravel 的创建者 this article 也会帮助您。