Search code examples
laravel-5laravel-facade

Laravel - Response:: or response() - which one is better


I was just curious about Facade and service container binding functions in Laravel 5.1, let's say Reponse::json() and response()->json() are the same. But is there any reason that one of them is better than the other?


Solution

  • It is already stated on the Laravel's documentation

    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.

    And this article by the creator of Laravel will also help you.