Answer the question
In order to leave comments, you need to log in
Why duplicate the namespace in the class name?
In popular frameworks, it is customary to name classes like this:
App\Repositories\UserRepository
App\Controllers\UserController
App\Repositories\User
App\Controllers\User
Answer the question
In order to leave comments, you need to log in
And when importing both classes, what will you do? That's why they are called unique names so that you can immediately distinguish one class from another. Moreover, this architecture (App\Repositories, App\Controllers) is not used in all projects. Therefore, it is logical to specify both the functional component (service, controller) and the domain one (user, app, article).
Frameworks are written not by 1, not 2, but by a large number of people. Therefore, a universal naming convention is created. In addition, different files can be located in the same directory under the same namespace, such as UserRepository and UserModel.
Habr recommend. Should answer your question. It's good that you're interested.
This article helped me a lot.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question