It's interesting that people are re-inventing parts of PHP in different ecosystems around this time. There is also the astro framework for example.
PHP has some properties that make it very suited for certain kinds of web development:
- stateless, very easy to reason about from a request/response cycle standpoint
- "serverless" and operationally cheap
- seamless HTML templating
- streams HTML by default
- batteries included
- straight forward and flexible first class data structures (associative arrays) with data literal syntax and value semantics.
- file based routing
Unfortunately, the PHP ecosystem has moved more and more away from that initial value proposition. Instead of cleaning and oiling this wonderfully productive and simple machinery, it wanted to grow into something else.
One can only imagine if PHP instead retained a focus on what made it unique and useful while making it more robust, secure by default and performant.
I wish it had focused on:
- making arrays even more ergonomic and leverage them more in general
- introduced a secure by default (escaping etc.) HTML template syntax
- introduced something like a load.php that can be used to keep some basic, global stuff in memory between requests
- improved on the idea of file based routing
- drastically improved error handling and introspection
As it stands now, it is on other ecosystems or even new languages to pick up the slack and try to capture what made PHP great.
Good summary, I made xtemplate with many of these ideas in mind. For example:
- Uses html/template which escapes content by default. This was already useful; e.g. the author name field is supposed to be a plain string according to the rss spec, but the google blogs include <name><company><department> tags which were automatically escaped by html/template. It's also easy to input raw html if desired, which I do after sanitizing it with the `sanitizeHtml` func (which uses the bluemonday lib) when displaying article content.
- It improves on file-based routing, by yes rendering matching files, but also by allowing you to add templates anywhere to handle any kind of request by matching method and path parameters.
- By default errors abort the request, but you can use the `try` function to get access to an error (if any) and handle it in-template.
- You don't need shared memory if you can query the db in 0.1ms :)
PHP has some properties that make it very suited for certain kinds of web development:
- stateless, very easy to reason about from a request/response cycle standpoint
- "serverless" and operationally cheap
- seamless HTML templating
- streams HTML by default
- batteries included
- straight forward and flexible first class data structures (associative arrays) with data literal syntax and value semantics.
- file based routing
Unfortunately, the PHP ecosystem has moved more and more away from that initial value proposition. Instead of cleaning and oiling this wonderfully productive and simple machinery, it wanted to grow into something else.
One can only imagine if PHP instead retained a focus on what made it unique and useful while making it more robust, secure by default and performant.
I wish it had focused on:
- making arrays even more ergonomic and leverage them more in general
- introduced a secure by default (escaping etc.) HTML template syntax
- introduced something like a load.php that can be used to keep some basic, global stuff in memory between requests
- improved on the idea of file based routing
- drastically improved error handling and introspection
As it stands now, it is on other ecosystems or even new languages to pick up the slack and try to capture what made PHP great.
reply