This post is all about what I think should be used to define quality in your choice of programming framework tool-set. This post is the first one of a collection of (unknown for now) number of posts.
This week, I had to bring to a team of people what I consider a good PHP framework and why I am sold. I am aware that I may sound blinded with my choice, but this post is about explaining my own guidelines about my choice. I work with them since many years and that made me try many in the PHP ecosystem.
Since we know that PHP can be a “sauce where everything goes”. Structure is crucial. There is many frameworks, many libraries, and to be able to build solutions that will solve more usefull and important matters, we need to agree on how to collaborate.
I do not claim to be a guru, I have done stuff and thanks to people I mention here, I feel I am getting better at the craft and I thought my reflection process was worth sharing.
Objective behind this series
This post is not an answer to a rant or an answer of a rant from a rant.
Actually, I think that bashing (or flamewars) never really been productive. Not to forget that ranting on a blog post from Fabien, one of the most important contributor to the PHP community, about how XXX feature is bad because of something else not related to the current topic. Is a display of disrespect on his work and do not bring anything to the table.
On the other hand, this blog post is my echo to many questions I saw on LinkedIn and discussions I happened to contribute and my own personnal process I use for everything I try to do my work.
My own experience
Value of one’s word starts with the credentials. So, here’s a little bit about my own personnal experience.
Between 2002-2005 I created my own CMS and CRM that I was calling Geranium. I did it alone, closed source, and I was the only one using it. This is to illustrate how I had the lesson learned. It was plain, procedural PHP 4, with lots of include and use of global variables.
I have to say that the most of my experience is about web standards than programming.
I always been about trying things and learning. Since then, to name a few, I worked with namely:
- CMSes such as: WordPress, Drupal 5, MODx evolution
- CodeIgniter, Kohana
- Zend Framework 1.09
- symfony 1.1, 1.2, 1.4
But, in my past I worked and had many discussions in either while I was organizer at ConFoo, and community events I was hosting during devLABs and other kind of events) in clean code architecture and principles.
PHP has a lot of bad code and tutorials (W3Schools is one of them that pops right in my mind). If you follow these, please stop right now!
But nowadays, there is good quality tools and efforts to enforce. And, quite frankly, without the work of my favourites contributors, I would probably had switched to an other language.
Like Fabien Potencier outlined, PHP has a lot of great stuff to offer nowadays.
Bottom line, if you are using old principles, why not start using tool-sets that actively teaches and promotes improved techniques.
Warning
Just to put it straight at the beginning. PHP is the language I use since a long while and I prefer to stick to it for a while as I am perfecting my skills in software architecture.
I have to say, I am sold to Symfony2. For the exact reasons of the ones I explain in this post.
I am personally open to other web technologies and will even give a try to Python
, Ruby
or Scala
some day. After Node.js
, of course.
What I defines a good project library to use
Going to the “real meat” now, shall we.
I think what is important in a programming language framework is the quality of the contribution, the steps taken to go forward and improve things, and promote quality. In the PHP world, there is many very competent contributors that exactly do that. I could name a few, but I would loose the goal of this post.
So what is really important in when you consider building a project.
To my opinion it is:
- Quality of the code contribution
- The community of people around it
- Reference to other work from people from other languages and concepts (not stay within your own flock and ignore the rest)
- Well written recommendations of architecture to use
- Guidelines of a way to implement, and more importantly why some other is being deprecated
- Clean OOP, namespaces, organization, Single responsibility
- Enforce typing as much as possible (method signatures anyone?)
- Scaffolding, Database abstraction, Object Relational Mapping, Repositories, Validation, etc
- Use of exting automation tools
¨
A part from that, I opened a community Wiki answer on stack overflow with the following:
Make sure what you use has, a way to:
- send to the log (Monolog is a good one)
- parse text only config (YAML is a good one)
- logic-less templating, with some convention (
Mustach
, Twig, NOT Smarty (please)) - dependencies definition manifests (Composer is the way to go, very similar to
package.json
that NodeJs offers) - define common “service” instantiation mechanism (DependencyInjection, Phemto are some)
- abstracted way to load libraries (ClassLoader component is a good one. You know, no hardcoded
require_once
) - Localization management (see Symfony2/Twig documentation)
- abstract database calls without hardcoding database vendor specific (Doctrine2, Propel)
- Unit testing structure, usage and conventions (PHP Unit, Behat, Mink)
- Database code doesn’t use “
mysql
” and istead usesmysqli
- Code generation mechanisms (also known as “Scaffolding”), see: Bob, and the ones built in Doctrine2 and Symfony2
- Code generation based on functionnal requirement description, see (Ruby’s) Cucumber/RSpec, in PHP it’s called Behat
- Database object class is as most possible vanilla (doesn’t extend ORM’s)
And all of that distinct functionality packages that you can mix and match aligned with what is not to be deprecated and the latest php features
That’s all for now
I could go on and on with a list. Stay tuned for my next post about my analysis on what I think great about those next generation PHP framework and tools. And most importantly, WHAT make’s them attention worthy.
Reference
Some good guidelines
- PHP The Right Way (contribute with a pull request here)
- PHP Framework Interop Group‘s PSR recommendation reference
My favorites contributors
This is my list of favourites contributors I look for when I read documentation and projects.
As it happens, I had the chance to meet them during my two last years as organizer of the ConFoo conference.
- Fabien Potencier, Symfony framework creator, and SensioLabs founder
- Doctrine2’s cookbook on CodeFirst approach, Object entity mapping and inheritance (aka. Inheritance mapping), and the others.
- Tobias Schlitt. Be sure to read his definition of a framework it is quite exhaustive.
- Jonathan H. Wage, creator of the best database abstraction layer, Doctrine
- Sebastian Bergmann and his peers at thePHP.cc
- Christophe Coevoet
- Johanes Schmitt
- Jordi Boggiano, and a big thanks for Composer
- People at Liip, their blog and projects is very informative
- People at KnpLabs, their contributions, Behat, and other projects are also very informative