-1

We are trying to run a couple of sites sharing about 90% of their code. The business domain is the same, but their UIs are a bit different. Hence they will have different CSS.

How would you manage the codebase to share the code that requires it?

2
  • Pardon me, but you have tagged your question as architecture. If everything is the same but UI whats the architectural question you have? Like how to include() relevant "shared" code bases? All this written currently is a question without enough context... Commented Aug 3, 2016 at 17:06
  • @close-voters This may sound broad, but is actually specific enough to be answered. Check here. the tags concerned are different, but the principle is quite the same. Sharing code is a specific concern in regard of php ecosystem. Commented Aug 27, 2016 at 2:13

1 Answer 1

1

Two general ways

  • Structure the shared parts as Composer packages

For instance, all the application level code, such as router, dependency managing, validation, domain entities mapping can be managed as Composer dependencies through Packagist. It's possible to use private repos as dependencies if code is not open sourceable.

You would then have a different repo for each site, and make the parts which are the same be built using Composer, and only coding the part which is actually different. You'd probably have two servers, for different domains.

This implies more configuration through Composer and code.

repo 1
    /app
        /viewSpecificToOne
    /public
        /cssSpecificToOne
        /jsSpecificToOne
        index.php
    /vendor
        /[dependencies installed through composer]
repo 2
    /app
        /viewSpecificToTwo
    /public
        /cssSpecificToTwo
        /jsSpecificToTwo
        index.php
    /vendor
        /[dependencies installed through composer]
  • Manage all the sites from the same repo

This is close to the other solution, but you would send the different routes to different front Controllers, who would use the same domain mappers, validation, routers, etc. but have two different View layers, that would feature specific code.

This implies more configuration from the server to serve each domain from the two public repos.

Repo
    /app
        /view1
            /viewLogicSpecificToOne
        /view2
            /viewLogicSpecificToTwo
    /public1
        /cssSpecificToOne
        /jsSpecificToOne
        index.php
    /public2
        /cssSpecificToTwo
        /jsSpecificToTwo
        index.php
    /lib
        /sharedPackages
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.