What is the PHP equivalent of writing your front end and back end in the same language so you can share libraries and data and not have to switch gears between two different languages each time you look up or down the stack?
There is a HUGE advantage to using the same language in the browser and on the server, and PHP isn't ever going to displace JavaScript in the browser. So JavaScript it is. That ship sailed a LONG time ago.
The value is really not in sharing code, but rather sharing developers. Instead of having to assemble and keep happy a diverse group of specialized professionals, you can just hire and fire a bunch of cheap JS folks, who are easily replaceable.
Offshoring already takes care of the cheap developers part.
When people get what is peanuts in local currency of the owner company, whatever they are using doesn't matter and most sweet shops are experts in everything.
I can also tell that at the level I work on, salaries are the same regardless of FE, BE, DevOps, ...., specially because no one has a single role.
toyg makes a good point about sharing developers, but also sharing code is important, especially for efficient server side rendering, with view code that runs on both the server and the browser.
The point is it takes fewer people (or even the same person) to write less code (instead of writing everything twice, then trying to keep them in sync forever).
There's a fascinating deep discussion about SveltKit and other frameworks here:
Reacting To Web Hot Takes from Rich Harris - SVELTE STUFF
> What is the PHP equivalent of writing your front end and back end in the same language so you can share libraries and data and not have to switch gears between two different languages each time you look up or down the stack?
You can simply compile your PHP code to wasm with emscripten, and then run it in the browser. Pretty straightforward. No more switching gears.
I like switching gears, I truly don’t find it an advantage using the language for both. Have separate languages makes the distinction between backend world and front end world very clear. Also the backend code is mostly data manipulation and the front end code is mostly rendering so there is very little overlap in similar functions for both. The separation helps keep things tidy in my brain.
I much prefer not having to write JavaScript everywhere, not every problem is a nail and not every solution requires a hammer.