Quick Tips

My Opinion About PHP

PHP has become one of the primary technologies while developing web applications these days. While working for Talentica  I can recall at that time there was only one project on PHP and mostly people were doing Java. After PHP5 it regained it’s strength and became one of primary stack for developers. I would try to explain what is my thinking about it.

There are 4 stacks that are very popular these days for an internet application to be built in.

  1. Java world – Spring/Grails ( I have worked on both)
  2. .Net world – Asp.Net/C# Combination
  3. Ruby World – Ruby on Rails
  4. PHP – LAMP Stack (Zend/Symfony)

Ruby on Rails, PHP frameworks and Grails are built around same philosophy i.e. Rapid Application Development. They follow an approach called Convention over configuration.

They all follow same development style and are supported by dynamic languages Grooy/PHP/Ruby. e.g. MVC is the universally accepted pattern for developing Web Applications now.

An internet application would typically have three layers.

  1. Presentation Layer – All frameworks provide a rendering engine to easily create web pages. Some even provide pluggable engines so you get a choice.
  2. Business Layer – Usually is written in one primary language but often interacts with external services.
  3. DB Layer – ORM like hibernate/GORM/ActiveRecord/Doctrine.

Almost all stacks provide an easy to use ORM layer which conceptually works in more or less same manner.

I do not see how someone experienced in GORM would have any problem working with Symfony ORM or Active Record.

Consider search which is a very important factor for a website. You will integrate a tool like Solr/Elastic Search in your application. It hardly matters what language you use for accessing Solr, you will still be doing similar calls.

As far as MySQL is concerned it is Database and is totally independent of language being used though there might be some differences in syntax of ORM layers. I have worked on C++/.Net/Java and Grails and I find myself equally at ease because underlying remains same.

Yes it is true that you can do faster development if you have someone who is experienced only in the stack you are using but things change when it comes to scalability.

Having said that largest of the applications today follow an approach called “right tool for the right job”. e.g. FB uses PHP as their Front End application but in the backed they have whole lot of languages including Java/C++/Erlang. That is how they achieve the scalability.

Facebook long before created a project called Thrift just to achieve seamless integration between different languages and is widely used today. I have used it myself to call Neo4J API in Java from .Net as .Net apis were not available for this graph database.

Even twitter story is very famous and they all solve their scalability problems on JVM and not Ruby on Rails which has been their primary stack for a long time.

PHP by design is not a multithreaded language and I am sure that people when they look for scalability they more often than not try to go to JVM and apache projects. This is called Polyglot style of programming where you do not stick just to one stack but do the right thing.

It is tremendous tool for creating sites quickly and gives many features/plugins out of the box but it can not solve all the problems a successful website will face in future.

I know some of the e-commerce company who quickly created a website by using Magento but now find it extremely difficult to scale due to it’s design of database which follows EAV model.

Though scalability is again subjective and it depends on what you are looking for. One may argue that many sites will never reach the scale of Facebook and Twitter but my argument is simple that if using right tool is the approach then it will not harm you. It is like Test Driven Development. Some people find it wastage of time but gives you robustness undoubtedly.

Take another scenario of NoSQL. I have used couple of NoSQL solutions and for a start up it is important to save cash, they do not try to Scale UP as bigger machines are quite expensive but scale out using commodity hardware. Hence NoSQL. NoSQL is analogous with Big data these days.

Again this is called polyglot persistence and is heavily in use today. It is easier to keep using MySQL but there are problems where MySQL does not scale well hence you look to add a new stack in your development process.

I have introduced new technologies time to time very systematically and that is how I have been able to solve scaling problems. These technologies at the same time have saved considerable time of the team. e.g. Using MongoDB we were able to solve long standing problems of sending and storing bulk emails for campaigns.

So I am of the opinion for different jobs different tools are required and they should be used systematically in a timely fashion. If right strategy is adopted they can give tremendous results in productivity and scalability.

As far as my experience with PHP is concerned then apart from fixing some bugs in an existing PHP application.

As part of my job I would not mind using or learning any technology including PHP but my effort would always be in the direction of doing the right thing keeping in mind time and budget constraints. Having worked in different stacks in my career I think this is something I really like about myself.