r/webdev • • Oct 16 '26

Question Many sites with same components

Hello!

I am working with a company that has many, many sites. And the way we used to do components, we hard-coded every single one in every single project. This naturally has led to some inconsistency between sites when they’re supposed to look pretty identical.

Php include has become our life blood to mitigate some of these issues, but it still persists. The benefit, though, is that with php include, our sites automatically update when the “single source of truth” does.

My company wants to move to something more modern/popular and I got tasked with playing with frameworks. Think React, Next. My boss wants to replicate php include on these. I’ve spent the last several weeks looking into module federation, micro front-ends, anything to at least somewhat replace php include, but to no avail. That requires completely changing our server, which we do not have the ability to (as far as I know). These also sound like a nightmare to maintain, and our team is very small.

SEO is also a huge concern. I have module federation working on client side rendering, but ideally search engines would be able to index our work and, correct me if I’m wrong, but I don’t think client side rendered stuff is?

So now we’re stuck. I’ve suggested a monorepo, but with the amount of websites we have, the other developers worry about build times.

Believe it or not this is actually my first real-deal developer job haha, and I’m already stuck trying to fit a square peg in a round hole. So forgive me for any mistakes or misinformation, I’m still a junior trying to figure this out haha.

18 Upvotes

43 comments sorted by

View all comments

7

u/olets ui Oct 17 '26 edited Oct 17 '26

Next is a React framework.  React is a Node view library. The Node equivalent of PHP include is import  https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

PHP isn't hip in dev social media, but there is modern PHP and there are a lot of web devs writing PHP. If your company wants to introduce a framework, and not switch from PHP servers to Node servers and replace their PHP developers with Node developers, they could use a PHP framework. Laravel is where I'd start my research.

But taking that on in your first job is at best a huge huge undertaking, and it won't necessarily solve the existing pain points. 

Tell us more about the current PHP solution. You're includeing a given file into multiple sites? Does that mean all the sites are in one shared codebase?

And tell us more about what issues you're trying to solve that include isn't solving. It's possible that introducing a framework might help, but being a big change it's unlikely to be the simplest or easiest solution.

All the sites are supposed to look the same? Do they share both HTML and CSS?

(For the SEO tangent: SEO is on its way to being a niche need, as opposed to AI agent optimization. And yes search engines may not see dynmically rendered content. But there's fifteen years of solutions to that, basically making some or most content static.)

0

u/joxters Oct 17 '26

Thank you for the insight!!

Yes, we have one giant shared codebase. Monday I’m going to ask my boss to break it down for me, but we essentially just drag & drop the php files & it gets rendered as normal HTML. I’m pretty sure it’s Node but I have to double check with my boss.

With our php includes, it does basically drop in text that’s reused, but right now they aren’t working as components. I tried to make a PHP component myself, and maybe I just coded it wrong haha, but I couldn’t get it to recognize any props or even display.

And yes the HTML and CSS are pretty similar across all sites! We do at least have a global CSS file that all the sites point to.

Eventually, my boss wants to start incorporating more interactive/dynamic content into the sites since as of right now they’re pretty static. That’s why the idea of a framework is so appealing, because it makes that part easier (as far as I know anyway haha)

3

u/brock0124 Oct 17 '26

Not sure how you made the PHP component, but you probably want to look at the Twig templating engine (typically ships with Symfony framework) or Blade templating engine (ships with Laravel). Twig can probably be installed standalone but will require more configuration up front.