avosalmon / modular-monolith-laravel

Sample application for Laracon Online 2022.

Home Page:https://youtu.be/0Rq-yHAwYjQ?t=4070

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What if i develop packages instead of using modules?

omarherri opened this issue · 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 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!

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.