I have been writing PHP for a good 20 years*, but before that I wrote COBOL, and I still write C after almost 40 years of it.
COBOL had a feature called templates - which could have been wonderful if it did what I thought it did, but it didn't.
The problem I want to address is that I quite often want to re-use PHP code for an application that is *almost* the same as another, but not exactly the same. For websites, this often includes an amount of (Postgre)SQL.
Consider, for example, code for a record collection - you have records, with titles, artists, Labels, release dates, Numbers, pictures of sleeve front and back, etc. You code up a page to list the catalogue, with filters and sorting, and a button to add a new record. Each entry has a button to select to see/edit/delete full details.
Now you want to do the same thing for a book collection. It is pretty much the same code, but the variable names are different. In some cases, there may be more or fewer fields, or the fields may be of different types, requiring different validation code, and the help and error messages need to be different.
It would be extremely useful to code up the basic functionality, and then have a facility to import it, translating the variable names, and other things using a definition process, so that these two things can be managed by different change management systems and maintained by different people. Also, the database record names, field names and types need to track the SQL code and that needs to map to the PHP names, type etc - which is not necessarily a 1-1 mapping. Sure you can skip this step, but then no human will be able to debug or maintain it.
Remember it might be highly desirable to have both the above implementations on the same website, in which case they might even share the same database server.
In the olden days, this is how we used Assembler, and those of us who were introduced to C as "the new PDP11 Assembler" (PDP11 was designed as a "hardware Fortran machine"), did this sort of thing as our normal work process.
Also remember that systems which auto-generate variable names like $V1002, $V1003, etc are not, in the real world, debuggable. Both originators and users are at risk of insanity. (I seem to remember Borland's drag-and-drop+ database stuff doing this, but it might have been someone else's). Oracle's PowerObjects was similar, until they discovered even Oracle's crack team could not make it Y2K compliant - possibly due to all the crack ( have no connection with Oracle other than them discontinuing PowerObjects killed my employer's factory work in progress management system, bankrupting the company).
It is possible I am going about this wrong, and should write the whole damn thing in C, but where the object is to produce a prototype, or code with a short expected life (eg "we have the contents of a library we want to sell like a garage sale") or similar,
the PHP is quite a good solution - build it, hack it till its more or less working, use it, and then throw it away). I do not recommend coding electronic power steering for cars, or railroad switching systems in PHP, but it does have good use-cases. Software for research projects might be one. The Uni could maintain a set of templates for an area of research, but individual projects could quickly create instances specific to their research project. The use of Uni-specific templates (written by IT professionals) making collaboration between teams easier, while the team could create project specific instances which support their workflow.
Yes, I know about frameworks, and this is similar in functionality, but significantly different in implementation and use.
My approach makes it possible to take the imported code, and give it a life of its own, rather than track changes in the template. While that would not be the primary deployment practice, there might be cases where it is the best option.
It should also be possible to use my approach to take a solution written in one Locale, and deploy it in another - or - potentially - automate systematically taking stuff from a popular locale (ASCII ?) and deploying it in a completely different locale.
* I am the person that suggested there is a Wii game that allows you to write PHP by throwing cow-pats at the screen with your Wii-mote - it might explain the quality of much PHP code.
+ a colleague of mine once said "the advantage of drag-and-drop is that you can drag it to the window and drop it onto the ground three floors below" (works best with punched cards).