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

andersonmaths's avatar

Deploy same code base too multiple sites

Hi All,

I've read all related posts but I can't see a "best practice" route to go down when it comes to establishing how best to deploy code to several sites on one server (only one server for now, we do have plans to add further servers).

Currently we develop locally, push changes up to a branch (without merging to master, as this is a means of versioning), then run an rsync script to update the files on the server for an individual domain. All the projects are working from the same codebase, although they are starting to differ due to this deployment processes that is resulting in differences starting to emerge, the intention is that they're all working from the same codebase however.

I've been told to look at Forge but the company I work for is unlikely to want to go down the paid subscription route. Besides, I can't see why this can't be solved without resorting to purchasing software.

So, I'm really looking for a starting point, I don't expect someone to detail a complete solution. Just an idea of how best to achieve a means of deploying to all sites.

My initial instinct was to have one Laravel install on the server and to use symlinks from each project/ domain's files to this one instance. The forum posts on that topic seem to suggest this is complicated, although they're not completely ruling it out as a possibility.

What are the other options? An rsync script that accesses each domain and only syncs "core" files?

I'm no sys admin, so I'm just unsure as to what should be aiming to achieve, once I know what I should be aiming for I'm happy to do the leg work to get said process up and running.

Thanks in advance,

Matt

0 likes
5 replies
topvillas's avatar
Level 46

Put the shared code in a package and use an rsync script (whatever that is) to run a composer update when you make any updates the package and it's version.

Or use Git hooks to get the package to update itself. I've never used Git hooks so I've no idea how, but it's an option. It's what Forge does but at a whole app level.

andersonmaths's avatar

Thanks for your reply Topvillas. Away from this thread I've had another person suggest I use packages to solve the problem. Sounds great in theory.

I have no experience of creating packages so far in my Laravel career, is it the case that all of my existing controllers, models etc. would be moved to a package or is it the case that I'm calling methods from my controllers that exist within a package that can be updated? In other words can I move the contents of my app folder (and resources for that matter) into a package?

andersonmaths's avatar

Hold on... official Laravel docs state:

On the other hand, other packages are specifically intended for use with Laravel. These packages may have routes, controllers, views, and configuration specifically intended to enhance a Laravel application. This guide primarily covers the development of those packages that are Laravel specific.

What about models? Can they be included in a package?

andersonmaths's avatar

Wonderful. I'll try my hand at creating one and see where that leaves me. Appreciate your help. Thanks!

Please or to participate in this conversation.