DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more
  1. DZone
  2. Coding
  3. Frameworks
  4. The PHP paradigms poll results: OOP wins

The PHP paradigms poll results: OOP wins

Giorgio Sironi user avatar by
Giorgio Sironi
·
Oct. 04, 10 · Interview
Like (0)
Save
Tweet
Share
9.93K Views

Join the DZone community and get the full member experience.

Join For Free

After two weeks of gathering votes, the PHP paradigms poll is now closed. With 216 votes (73%), the winner paradigm in popularity is Object-Oriented Programming. The old procedural approach to PHP, which has given fame to Wordpress and Drupal, is coming to an end. Even Drupal 7 has an object-oriented database layer as a primary component, and this paradigm is by far the most diffused in the world for web sites and applications written in high level languages (different from C).

Only 6% of votes went to procedural and the 8% to spaghetti-like programming (which we can take as a joke, I hope).

The functional paradigm makes up for the remaining 13%, a growing minorance in the PHP world.

PHP is not LISP and this is not a mistery either. However I feel that the functional constructs would become a well-treated minority in the codebases, able to fill the gaps where using an object or a Command pattern would be needlessly verbose.

We already know several situations where anonymous functions and closures come handy: the returnCallback() matcher in PHPUnit, or the small methods for formatting domain data (in the realm of View Helpers). There is also a PHP 5.3 adoption curve that has to be considered before they can be included safely in our projects. We all hope this curve won't be steep.

Frameworks vs. CMS

OOP emerges as a winner since while in the previous years the buzz in the PHP world was always on CMS and Wordpress, due to their long list of features, now it is on frameworks, due to their flexibility. Frameworks are naturally oriented to objects, to scale at a level of complexity never imagined before.

In a single page of a framework-built web page, you can leverage components like layouts, database queries and updates, access to web services, cache and formatting of currencies, internationalization and more. All dealt with and kept in its place, while adding a new page becomes a matter of ten or twenty lines of code.
The only problem with object-oriented programming in PHP is the lack of support from the language, which is evolving fast as I commented, but not in all the directons and certainly not on the most correct track.

>[...] the OO paradigm of PHP 5 borrows heavily from Java, and with its object handlers system gives the possibility of building large object graphs like the ones of frameworks such as Zend or symfony. There is still much work to be done however - SPL really sucks from a design point of view (its component are used for performance), and things like collections or lists still have to be created in userland code.

Fortunately, frameworks implements in userland code what is missing. PHP as a language is fairly complete (compare it to C); the problem is in the lack of object-oriented libraries directly available with the interpreter. Java has its Collections Framework; PHP has arrays. PHP has many features for accessing web services or managing internationalization, but they are not object-oriented: we make up with frameworks all the time.

There is a tie-in towards the framework, or ORM however: the upcoming Doctrine\Common\Collections\Collection is an example. Try do lazy loading with an array: you can't. So application code growing dependent on the library is something we must accept for now.

Conclusion

On the whole, object-oriented programming and libraries are able to make PHP scale in complexity instead of in user size, in directions like the enterprise and workflow systems. It's no mistery why it won this poll.

You find this result consistent with what you're seeing in the PHP community?

Object-oriented programming PHP

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Running Databases on Kubernetes
  • A Beginner's Guide to Infrastructure as Code
  • Real-Time Analytics for IoT
  • GitLab vs Jenkins: Which Is the Best CI/CD Tool?

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: