I’m proud to announce the first release of the php mvc framework Mendo Framework, an (H)MVC framework for building web applications in PHP!
One might wonder, why would anyone create yet another MVC framework when there is a vast choice of them already made available?
I used to develop web applications using Zend Framework 1 in the past.
I was using the infamous global singleton
Zend_Registry application-wide. I loved it! I could get any service from any Controller by simply accessing it in a static way like
Zend_Registry::get('someService'). The Model layer contained only Data Access Objects encapsulating the SQL queries, returning arrays of data from the DB; there were no Domain Models whatsoever. The famous tutorial of Akrabat didn’t use Domain objects as well, Controller actions looked like:
$albums = new Application_Model_DbTable_Albums();
$this->view->albums = $albums->fetchAll();
Application_Model_DbTable_Albums didn’t contain a single album property, instead it contained only methods for retrieving, saving and updating the database.
My application logic was spread across controllers, and occasionally even in the views. The more the application grew, the fatter the Controllers got, the more code the view templates contained, and applications became quickly unmaintainable and just too tedious (and extremely boring) to work on. The framework felt bloated, but still didn’t seem to suit for bigger applications.
Something was definitively wrong…
Then Zend Framework 2 got released end 2012. I was very excited about its impending release as it was the opportunity for me to start all over again, on a good basis; the framework seemed quite different too. I wanted to become a better programmer. I knew I was doing plain unmaintainable sh*t. It had to change somehow, anyhow. So I delved into the ZF2 documentation. It was hard. But I persevered as I was REALLY decided to become better. I tried again, and again, and again, … finally realizing that the documentation was maybe not a good start for a noob like me. I switched to YouTube, watching online tutorials, conference talks on ZF2 about what had changed and the new concepts that were introduced. Well… feeling hopeless I came to the point where I typed “Zend Framework 2 sucks” in Google 🙂
Surprisingly, I was not the only one who was shocked about the monster that ZF became. You had to set up that Virtual Host (instructions for shared hosting, please?), then configure the application through huge configuration file, without having any idea of what I was doing, … NO WAY, I had enough of being that developer just doing what is being told in the manual with no understanding of how things work behind. I didn’t feel like I would ever learn anything in this way and would repeat the same mistakes I made with ZF1.
At that same time, Laravel was doing a huge buzz. Everyone was talking about that new MVC framework and how easy it was to make web applications and producing clean code.
I delved in its documentation and installed its skeleton application. First thing I wanted to know, is how to divide my controllers into multiple modules.
In ZF1 I used to have e.g. an admin module for the admin area, a member module for the member area, etc. This allowed me to group related controllers together and to define ACL rules per module.
I couldn’t find a way to do that easily/natively by Laravel; I searched for help within the community, but it seemed I had to change some config files in order to achieve what I wanted to do.
However I expected to have this by default, as it seems a very basic requirement. Although it was possible to make “bundles” or “packages” or whatever they call it now, the admin area wasn’t meant to be reusable, same goes for the member area, so I wasn’t really into this idea.
The other thing that bothered me is that there is quite a lot of “magic” behind the framework, again, at some points I had not a clear idea of how things worked behind the scenes.
With all this hopelessness, eventually I thought I would better go with no framework at all. I then started to code my own custom framework.
I really enjoyed coding on this project, to such an extent that I was trying to improve it constantly by all means.
I started to read more and more articles about good programming practices, which before seemed completely beyond myself.
By putting these into practice, I gained a lot of knowledge, and the more I learned and implemented new concepts into my own custom framework, the easier it was to understand other new concepts.
Putting daily into practice some of these new concepts definitely changed me as a programmer. These include:
- DI, DIC and Composition Root
- Composer (for making re-usable packages)
- SOLID (Don’t be STUPID)
- KISS and Clean Code
- Mark Seemann‘s articles on DI, OOP best practices and Design Patterns
- Tom Butler‘s articles on MVC
The result of this long way of learning, thinking, a bit of coding and a lot of refactoring, is the php mvc framework Mendo Framework.
Mendo Framework is a framework based on Pimple Dependency Injection Container. All the components building the framework are services (which can be replaced by another custom service in the container) and developers can add any additional services to the container. Services (the ORM, a logger, ACL, etc.) are passed to MVC components like the controller or the view model through their constructor at the composition root, resulting in clean APIs.
A lot of components are completely loosely coupled from the framework, having their own GitHub repositories (acl, auth, form, logger, mailer, mediator, translator, …) and tested by PHPUnit.
Mendo Framework redefines how to develop PHP MVC web applications with a better OOP approach by introducing some concepts that the general PHP world may not be completely familiar with.