vernancheta25's avatar

How to extract general functionality to a package

My boss wants me to copy almost the exact same functionality from one project to another to save time. I'm really against this because I will have to copy and paste code, and then maintain both codebases later on. What's your recommendation that I could do to make this task more fun. I don't really want to do the default option which is to copy and paste code.

For context, it's a simple ecommerce website. Users can create products, design their own store, accept orders, etc. I'm thinking of extracting all these functionality to a library or package of sorts which I could then just call with ease from both projects. Something like an ecommerce core library. Obviously, this is going to need some frontend as well. So if I could just extract all those common functionality (with their corresponding frontend views and scripts), put it in a package and then use it from both projects that would be ideal.

Am I going in the right direction? If so, please give me guidance on how should I go about this.

0 likes
1 reply
automica's avatar

@vernancheta25 this is a good package to use to create Laravel packages

https://github.com/Jeroen-G/laravel-packager

you may also want to combine this with Laravel modules, which allows you to separate front and backend fuctionality

https://github.com/nWidart/laravel-modules

you should encourage your boss that spending a bit more time finding a way to share functionality means you don't need to maintain two separate code bases and test suites, and its also less cognitive load for you as developer.

Cheaper to spend time developing a shared solution than it is to bug fix live releases.

2 likes

Please or to participate in this conversation.