Pixelairport's avatar

Change Laravel structure (User in DDD)

Hi... it is one of the days I think about something, which is not really a problem... but keeps me away from go on working :) and I wanted to ask, what you think.

I work on an app, where i know there will be a lot of code. So I started to learn some new things... like DDD. I think about structure for Application code and Domain code and I think about the user (and also fortify, which is placed in App\Actions), which comes out of the box with laravel. I want to restructure the user and put it in "Domains\User\Models\User.php" instead of app\Models\User. Also Fortify or Middleware like Authenticate should moved to this domain. Or maybe Fortify actions into App\Customers\Actions.... Not sure, but what would you think about moving it from moving the user stuff also in a structured way instead just do a better structure for everything else and leave only users in the "normal" structure... will there be maybe other problems I dont think of now in the future if i restructure it?

0 likes
2 replies
Tray2's avatar
Tray2
Best Answer
Level 74

I would stick with the existing structure just not to get any headaches in the long run. The MVC structure is proven to work just fine. However, you can place your code anywhere you like as long as you keep the namespaces up to date with that structure, be aware that you might need to make changes in some vendor files if you move stuff around.

1 like
Pixelairport's avatar

thx @tray2 ... I also thought a bit more about it and tried to restructure it, but it looks more complex after this, because the normal structure is learned. I think it is better to leave user stuff like user model, fortify, middleware, ... in the main app folder. I only build domains for each thing which is not part of user and not part of application code. And maybe break some domain down to packages. Thx for your help tray2.

Please or to participate in this conversation.