modular-monolith-laravel icon indicating copy to clipboard operation
modular-monolith-laravel copied to clipboard

What if i develop packages instead of using modules?

Open omarherri opened this issue 2 years ago • 1 comments

Thank you for your presentation. I subscribed to your twitter account :)

I was wondering what if instead of developing modules apart, i can create package for every modules so that i can use them in my main application. This would still respect the domain boundaries ?

omarherri avatar Feb 28 '22 21:02 omarherri

@omarherri Thank you for watching my talk!

I haven't tried this approach myself, but you might want to look into laravel-modules package. I'm not too sure if you can extract a module as an independent composer package though. For example, if some code in the module might depend on classes in the app directory, the package wouldn't have access to those dependent classes. Also, a package will have a dependency on another package if it depends on another module (e.g. interface, DTO).

Would like to know how it goes if you have a chance to give it a try!

avosalmon avatar Mar 13 '22 03:03 avosalmon

I followed you principales and i feel more confortable now about the outcome.

So to tackle the dependency between the packages i created one package which contains all the contracts and DTOs. And in the other packages i just require this one in composer and implement the interface needed by my application.

The benefits with having a package for every module, is that my main application is so clean and light and i can have many application that uses the same code source and i can update theme easily with composer update.

omarherri avatar Sep 13 '22 09:09 omarherri