Search code examples
phpfacebooklaravelfacebook-appslaravel-socialite

can't understand facebook authentication using laravel


I'm going through this tutorial to implement Authentication using facebook

http://www.codeanchor.net/blog/complete-laravel-socialite-tutorial/

but I can't exactly understand the UserRepository, and AuthenticateUser ,,, why we should use them like this , not simply put the functions on User model and User controller and AuthController ?


Solution

  • The reason is that UserRepository etc are classes which handle a specific function thus you are injecting these objects as required. Putting all of them together could still work but it becomes difficult to maintain in the long run if you do not have a clear seperation of concerns.

    The value of separation of concerns is simplifying development and maintenance of computer programs. When concerns are well-separated, individual sections can be reused, as well as developed and updated independently. Of special value is the ability to later improve or modify one section of code without having to know the details of other sections, and without having to make corresponding changes to those sections.

    read more:

    https://en.wikipedia.org/wiki/Separation_of_concerns