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

giuseppemastrodonato's avatar

Best practices for code/repository management

Hello guys, I developed a CMS based on Laravel and I wonder what is the best way to reuse the system for further projects.

Going straight to the point, I created a repository "CMS" which I clone everytime I want to create a new project with the CMS. Then, I create the website adding the template files and the (eventual) customizations to Models/Controllers.

Now, when I make some improvements to the mother repository "CMS", what is the best way to reflect the changes to the other websites?

What is the best practice, using GIT, to handle this flow? Forking the initial repository?

Looking forward to hear your feedbacks!

0 likes
5 replies
martinbean's avatar

@giuseppemastrodonato Your "mother" repository should be added as an upstream remote, so you can pull changes into each "child" repository:

git pull upstream master
giuseppemastrodonato's avatar

@martinbean can I add it as upstream also if the "Child" repository is a "modified" clone (so basically a completely different repo)? Or do I have to fork the mother and then add it as upstream of the child?

martinbean's avatar
Level 80

@giuseppemastrodonato You should be forking the parent repository, otherwise the child repository wouldn't have any common ancestor commits, and will probably give you a nasty merge conflict if you tried to pull the master branch of the parent repository into your child repository.

But, it's difficulties like this why a lot of content management systems have gone down the package route, in that the CMS is a package you install using Composer into a new or existing Laravel application, and then updating is a case of running composer update your/cms rather than trying to keep multiple Git repositories in sync with an upstream one.

martinbean's avatar

@giuseppemastrodonato Well a package can have its own routes, controllers, views, configuration etc. So a lot of CMS vendors these days are making their CMS a package that application developers can add to their composer.json file. That way, when a new CMS version is released, all you need to do is run composer update, rather than having to mess about pulling from other remotes in Git.

Please or to participate in this conversation.