I've been working on a solution that will allow me to write my front-end application in PHP. Why? - I wouldn't say I liked the idea of using Node js on my servers for server-side rendering using Vue or Angular. Don't get me wrong, I work with .NET, Node js, Angular, and React every day at work and have nothing against it. But I needed a simple component with some data from a server and rendered using a template for my side-project. So, I started to think, can I convert my PHP code into Javascript? - Sure I can. Classes will become functions, private properties - local variables. Protected and the public will become public properties, etc. Something like this:
class TodoApp extends BaseComponent { public string $text = ''; public array $items = [];
public function handleSubmit()
{
$this->items[] = $this->text;
$this->text = '';
}
}will become: var TodoApp = function () { var $this = this; this.text = ''; this.items = [];
this.handleSubmit = function (event) {
$this.items.push($this.text);
$this.text = '';
};
};By following that pattern, I designed a first working prototype. It was pretty good but most important - it supported SSR out of the box. Later I added more and more features, like templating engine, reactivity, built-in PHP functions support, etc. And I could not stop. I continue improving it every day in my free time. As of today, Viewi is a fully functional tool for building full-stack and reactive web applications.
Link with some examples: https://viewi.net/
Documentation https://viewi.net/docs
Architecture design and idea https://viewi.net/docs/architecture and here https://viewi.net/docs/introduction
Tutorial https://viewi.net/tutorial
GitHub project https://github.com/viewi/viewi
I hope you will find something useful for yourself. Feel free to ask questions or leave feedback.
Thank you!