Description:
Code can be tested with PHP โ php -S localhost:8000 index.php
The MVC components are in separate files to demonstrate real-life advantage in avoiding conflicts for people working in large teams.
Process:
First I wanted to use EventListeners to handle communication between Model and View classes. This was successfully implemented by me in JavaScript MVC example. However, due mostly to the lack of knowledge I could not achieve desired results. I created classes and assigned parameters to them. Handling the press event is made with PHP's isset
and GET
functions.
References: Implementation is strongly influenced by Callum Hopkins and his article about MVC pattern and PHP on sitepoint.com. It is the part one of his series on MVC pattern in plain PHP
Dair Baidauletov
30 Jan, 2018