That structure looks fine to me.
Where to put models in Laravel 5 ?
Hello guys ! I know models are in /app, but i'm trying to build mid to large application, so i want your suggestion about app structure, and namespacing too! I have one app structure in my mind and it's like :
/app
...
/Commands
/User
UserRegistrationCommand.php
/Handlers
/Commands
/User
UserRegistrationCommandHandler.php
/Models
User.php
Recipe.php
/Repositories
UserRepositoryInterface.php
UserRepository.php
RecipeRepositoryInterface.php
RecipeRepository.php
I'm really stuck at the app structure and it's namespacing convention !!
If you're building a large application, group your classes around your domain concepts first and their role second. For example, In your example, I would have this structure:
/app
/RecipeBook
/Domain
/Recipes
/Commands
CreateRecipeCommand.php
RateRecipeCommand.php
/Handlers
CreateRecipeCommandHandler.php
RateRecipeCommandHandler.php
RecipeRepositoryInterface.php
Recipe.php
/Users
/Commands
RegisterUserCommand.php
/Handlers
RegisterUserCommandHandler.php
User.php
UserRepositoryInterface.php
/Infrastructure
/Recipes
EloquentRecipeRepository.php
/Users
EloquentUserRepository.php
In my experience, it's much more useful to organize your code by how likely they are to interact instead of their similarity in function. It's not useful to have all your repositories, models, etc in one namespace, because stepping through your application's execution has you mentally jumping back and forth all over the place.
Please or to participate in this conversation.