Page 2
8 Dec
Admin

A Look Back at Object Oriented Programming in PHP

We have been using PHP since so long. Sometimes, I wonder how long has PHP been with us and to get answer to this question; I looked back at the time when PHP came into existence i.e. in 1994 when the original development was started in PHP.

The original release of PHP took place in 1998 and it has been 21 years since PHP is with us. We can say that PHP has a very good lifespan on the web because very rare technologies stay for so long. So, let’s take a look at the entire journey of PHP in the online world.

PHP Development

The initial stages of PHP:

PHP came into being with its first version known as PHP 3. During that time, people had just started learning the basics of programming and very few were about objects as well as object oriented programming.

PHP was something which was easy to learn and grasp. This was to be used for scripting as well as for driving terrible web pages. Most of the developers tend to learn from examples as well as work from other people.

They used to follow the same process to get the results. At that time; there was a large procedural file which was divided into various pages between different files. It was very tricky to develop web pages because sometimes they would post a separate file.

Had there been post variables then it would have become easy to develop any pages and then just display the page as it is. As soon as people started learning the techniques and getting more knowledge about objects as well as some other best practices then they started understanding that some things they did were completely wrong.

During those times; web meant large procedural files where codes were shared with certain statements however most part was with no frameworks and there was a wrong mindset that anything can go well.

The best example of this is early versions of phpBB. It is the main loop to develop forums and indexes or content pages is a very huge procedural mess. It has amazing code comments. The original developers found it as a complete mess.

The main drawback is that this render loop is now replaced with 10-20 lines of angular.js code and this is the true power of objects and frameworks.

Middle Age PHP 5:

Till now, whatever we were discussing was about PHP 3. Now, we will discuss about PHP 5. So, let’s move ahead:
By the time PHP 5 arrived, we got maximum support from Object oriented programming. We also got lot of in built functions in PHP having object equivalents. Just there’s a need to checkout date time documentation and you will get to know what we were talking about.

So, we have various objects and we are going to create a code using PHP 5 but here there was a huge problem. Let’s say if you have a file which defined a class then it can easily be overridden by another file which was included later on if it also had the same file with defined class. PHP overlooked namespaces.

For most parts this was not at all a problem. Generally, developers were in full control of their project and hence they made sure that none of the things were to be named the same. When the codes were shared, things started to fall separately.

This means if a widget developed by one developer is to be used by another then one had to make sure that all the classes were to be named differently from that which was used previously or the widget could not be used.

PHP 5.3:

Here, in this version the biggest problem was namespaces. In case you are unfamiliar with namespaces then we can define them for you as “an Address for your class file”. One can have multiple classes with the same name and if the namespace is different that it is fine.

Various other object oriented languages use this concept to sandbox code as this makes it easy to share and reuse pieces. The only issue with namespaces is the way they are implemented. Other languages use a (.) to divide names of namespaces however PHP uses a back slash (\).

Developments:

From the beginning itself, index.php files are cluttered. In case you are using lot of different files then at times there were tons of those which included at the top of a file. With the use of classes, the app simply knew about classes.

This resulted into a paradigm of index.php which included everything. With small apps; this is not a bad thing however for larger apps; it is like a death statement. Every request on PHP should only really load the classes which are required to fulfil the tasks at hand.

There are many frameworks that include a dynamic class loader but these are easy to develop if you want to try them for yourself.

Wind Up

Hey, here we haven’t discussed anything about PHP 7. However, this was the blog post about PHP journey till date. Let us know how you feel after reading the same. Did you enjoy? Is anything remaining to be added?

We, at Softqube Technologies; a well known PHP web application Development in India are always eager to listen to the views from our readers after all everything is about sharing and caring.

contact
Are you looking for real talent for your dream projects?
Inquiry
We will respond you in within 24 hours
Do you have a project in mind?
Let's start your project
Quick Contact
We can give you a fast response via email, phone call or skype.
For business inquiries
Call us on
Let's Skype
Close
Inquire
Let’s make something awesome together!
Drop us a line, or give us a heads up if you’re interested in visiting us.
  • Accepted file types: docx, xlsx, ppt, pdf, jpg, gif, png.
  • 11 + 4 =
  • This field is for validation purposes and should be left unchanged.
100% secure and private