Zend Framework 2 – The Next Revolution in the World of PHP

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

When I first encountered the Zend Framework I was blind-sighted by the high level of abstraction, the clean code and the rich library. I was 18 years old then, and my OOP knowledge was limited to developing simple websites that utilized a couple of classes + Smarty. In theory, I knew everything about OOP but I had no conceptual idea how to take advantage of the power of this technology – I had only heard using classes and objects was cool. Zend Framework has played a major role in my professional development and has managed to completely shift my worldview, transforming my then idea of coding into something quite different. Zend Framework has taught me to think object-oriented.

Every coder, who is familiar with OOP in theory (but not, for instance, with design patterns), has the illusion that they have no need for community-wide approaches, that they are great and have no need to learn from anyone else. This is what I see in almost every PHP coder nowadays. Before I came across ZF, I too was a bone-headed beginner.

Let me describe а project which does not utilize a framework: it has a single class, often named either Main or Core, and contains various methods – from database connections to product information retrieval, to as far as user registration. This is the Mothership. It is thus often the case that the Mothership includes over 10,000 lines of code, and is the author’s ultimate pride. Some programmers measure their… lines of code, but in the source code, quantity != quality.

The transition from this obsolete style to object-oriented thinking can be very difficult (utilizing a couple of classes does not make your project object-oriented but rather an object-disoriented one).

When I found out a year ago that a new version of my favorite platform was under way, I was more than sure that there’d be a ton of new stuff to learn and I had the feeling that Zend was going to change the world of PHP once again.

So, what was wrong with Zend Framework 1?

Although I have very sentimental feelings toward ZF, I cannot ignore the fact that there are a lot of things in it that I dislike.

A clumsy module system

The module system inside Zend Framework was added at a later time. In earlier ZF versions no attention had been paid to modules, which meant that the module option was fitted in afterwards. Many important options had been omitted such as module configuration and a configured classes-loader. All these things were not that difficult to mend but they did get on people’s nerves.

Continue reading “Zend Framework 2 – The Next Revolution in the World of PHP”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

Can’t Imagine Life without Dependency Injection – Part One

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

There are two types of programmers in the world of PHP. The first is the curious, the knowledge-seeking type attempting the most elegant and clean solutions of development issues, who strive to create a harmonic picture of code that evokes admiration, and not an infinite torture of the soul. The second is the indolent type, always pressed for time, who experience coding as if it were a sort of mining activity. In the source code, however, quantity != quality. In time, I have realized that in this realm the moment never comes when you can say “I am ready! There’s nothing more I can learn!” New methods and approaches are continuously developed that aim to make life easier for the programmer.

Recently, there’s been more and more talk in the PHP community about Dependency Injection (DI) – and there’s a reason why. In my own judgment, the development of Zend Framework 2 and Symfony 2 has significantly increased the popularity of Dependency Injection (in PHP) and has shed light on the importance and great advantages of this design pattern. Despite the numerous blog articles, PHP coders still seem to shun this approach. Below, I will try to explain my understanding and implementation of DI.

So, what exactly is Dependency Injection?

Dependency Injection is a design pattern. A lot of people are unable to tell the difference between Dependency Injection and Dependency Injection Container. Now I will try to elucidate DI, and I will discuss DI Containers further down.

Continue reading “Can’t Imagine Life without Dependency Injection – Part One”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone