Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gitwithravish's avatar

Multiple projects that requires same database and model layer

I am working on a corporate project. We have multiple modules (4 to 5) whichhave to be connected to the same database.

But some of the modules will be uploaded on subdomains. e.g. www.xyz.com, www.admin.xyz.com

And some on completely different domains. e.g. www.xyz.com, www.abc.com

But everything is a part of a single project. The database is common.

What is the best way to handle such kind of project?

There is a similar discussion on the following link https://laracasts.com/discuss/channels/tips/multiple-projects-on-same-database

But I am a beginner, so I am not able to understand it properly. If anyone can explain to me with little more details, it would be very helpful!

0 likes
1 reply
bobbybouwmann's avatar

I would probably use modular packages. So you just create a regular PHP package that holds all the models. And then you create a package for each shared functionality. This way you can develop it on its own and whenever you update it all other systems will get this update as well. This is more the composer way of doing things.

Another solution is using submodules in git, but I'm personally not a fan :P

Anyway, here is more information and tools for building packages: https://phppackagedevelopment.com/ and https://laravelpackageboilerplate.com/#/

1 like

Please or to participate in this conversation.