And that unfortunate school of thought created the Java mythos that spread to many languages, not only PHP, eg JavaScript (everyone trying to write inheritance based OOP in a prototype based language).
Few years ago the mythos changed somewhat to every programming language should be functional.
Thus it is not a specific PHP problem, it is common problem of trend sensitivity in programming culture.
And the funny thing is that much of the critique against PHP, like in this thread, is in the form of "why isn’t PHP like the other programming languages?"
But agree PHP should go it’s own way, it has much to contribute to the world still and it feels like it has started to create its own path again.
I don't think it's as simple as OOP being bad but rather the culture of complexity that everything had to have deep object hierarchies, layers of indirection and runtime configuration, etc. If you write Python, JavaScript, PHP, etc. classes which don't try to follow the enterprise Java style and only pay for the complexity needed by the problem domain the results are fine.
I think a large part of it was that many people learned not OOP but how the Java standard library and J2EE worked, and internalized the idea that you were trying to produce a reusable abstraction for the entire stack which could be used by unrelated projects without realizing how expensive that kind general framework development is.
What I was trying to say was that the inheritance based OOP was sold as the ultimate problem solver.
We all remember programming classes with Hello World like examples of Cat inherits from Animal.
Problem is of course that in the real world is never that simple so the inheritance based model turned out many times to be a mess because it was applied to problems where it didn’t fit.
That doesn’t mean that inheritance based OOP has its place, it does, but that is usually in very specific domains.
It would make a nice counterpoint to all OOP-style web dev languages (Django, RoR, PHP8+framework + routing logic) and all frontend-focused frameworks (React, Vue). Super-simple, super old-fashioned, but rock-stable and easy to kickstart a small website or prototype, and great for teaching (nothing is easier than "drop a index.lang" file in this directory and you have a website).
There's not much in PHP 5/7/8 which precludes just doing some raw db queries and including some templates.
The biggest 'drawback' might be that there's not one name-branch 'framework' which takes this approach (indeed, it's the opposite of 'framework' thinking). But if there was some project that documented/demonstrated 'best practices' for 'non-framework' projects, it might help reduce the "I need a framework because raw PHP is so messy" objections.
Exactly! That comes close to the point I wanted to make
1 - security-safe and type-safe from the beginning 2 - none of the additional programming paradigms. PHP wants to be everything in one language. I know you can still use PHP "basics" like that, but it's not going to be easy to find tutorials etc. showing that
The main point I wanted to make was not about the index.php file. In other words, I'd like a PHP3, but a clean, safe, very well-designed one.
It does surprise me to encounter over-complicated Java-style patterns in PHP.
I am not sure it would have been practical to turn PHP into a strongly HTML aware template language like Thymeleaf for example, while still having it be useful as a general purpose programming language. IMO, the dream of PHP/CFML/JSP/ASP mixing code with templates just isn't realistically possible.
<title>bla</>
<?php let x =
"<p>whatever</p>"?>
&x
<div class="debug">
<![ RCDATA [
&x
]]>
</div>
where x is bound to markup checked against permissible elements in the first context (eg rejecting <script>) and escaped into <p>whatever<p> in the second. Rejecting script elements in user or other dynamic content as well as escaping comes for free with regular SGML parsing.Plus, what makes you expect this opt-in syntax would catch on if people already don't care enough to use HTML-aware template engines?
EDIT: Also, what happens if the static parts of the document aren't syntactically correct SGML? How can you even know if the final output will be syntactically correct SGML until you run all the legacy parts of the PHP code that output directly in the document stream?
Re: conditionals SGML allows marked sections to have parameter entities as keywords, and recognizes INCLUDE/IGNORE in their expansions:
<!entity % e "include">
...
<![ %e [
will only be included if
e expands to INCLUDE
]]>
Re: mixed user/system text
SGML supports quite restrictive content model exclusions, eg the "-(script)" part below makes SGML reject script elements in main's content anywhere: <!element main - - ANY
-(script)>
Moreover, you can declare an entity as a so-called data text entity, special chars in which are preservedRe: running legacy parts There's no difference to what PHP does now eg just running through the page/template doc until the end, erring out on validation errors?