Web
Article

On Our Radar: PHP 7 Controversy and Dependency Injection

By Paul Wilkins

Over the past eight months, we’ve enjoyed bringing to you the latest and greatest updates from the world of web development. But we’ve also noticed that discussions among web professionals on our forums have not been receiving nearly enough exposure as they should.

To change things up a bit, we’re going to start bringing to you items and information from those discussions that have caught our attention. Sometimes these discussions will be useful and interesting, and sometimes they may be challenging or insightful. Either way, they’re likely to bring new information to light that you haven’t come across before, and will help to provide insight and perspective on topics you’re interested in.

So let’s get started!

PHP 7 Controversy

The PHP 7 Revolution article brought on a vast amount of discussion in our forums. The article covered information on how PHP is skipping 5.7 and moving directly to PHP 7, that the new version will give us return types, and that the removal of PHP4-style constructors is certainly going to be a controversial change. Tony Marstron controversially pleaded: please don’t break our language.

An excellent response from rrcatto:

“If a business needs to run a piece of code, to me this also implies actively maintaining it. … If the language changes, code must also change. That is the only dev paradigm that makes sense, because progress is a good thing and we should not hinder it.”

The conversation continued at length, with great insights provided.

Dependency Injection is Evil

A highly controversial topic — dependency injection is evil — also came up in the discussion on PHP 7, and was (usefully) moved to a separate thread for examination.

It seems that some of Tony’s articles voice opinions that are controversial and oppose the norm, and this one on dependency injection really struck a nerve with some.

Jeff Mott summarized the Pro case quite well, with:

“Dependency injection makes code more flexible and more decoupled.”

Others too attempted to examine the reasons why Dependency Injection may be bad, to find out whether any of the claims had much ground to stand on. Another key point was also great to see:

“[R]equirements change all the time, and therefore software changes all the time. Today, an important factor that makes an architecture good or bad is how adaptable it is to change.”

While it can be tempting for dissenting opinions to color how you feel about that person, it’s vital for such conflicts to occur for it is only by shining the light of inquiry on the problem space of controversial issues that we can find out where we stand on the topic, and find the most suitable solutions.

It’s also illuminating how even though disagreement occurs on the techniques that are used, rarely do the parties involved resort to personal attacks. Instead, we see an examination of the ideas being presented, which is something that we can all aspire to.

Your thoughts?

That’s all from us this week. What do you think about the change of focus? Could we do with more threads being examined? Are there any important threads that we could do with examining next week? We would love to hear your thoughts.

Comments
zackw

By the time common cheap hosting companies are adopting PHP 7, all relevant software, CMSes, frameworks, libraries will already have long since updated to new coding standards supported by PHP 7 anyway.

My point is, this is all "controversial" right this second, mainly because nobody anywhere actually has to adopt PHP 7. My prediction is, just like other versions of PHP, we won't even see PHP 7 as the common version for like 5 more years, by which all common libraries will have already been updated.
Heck, I still use extremely popular hosts which still support PHP 5.4 or older. Wordpress can still run on 5.2 though they recommend 5.4. By the time 7 becomes a requirement and is common, we'll already be talking about the controversies in PHP 11.

Hall_of_Famer

But PHP 7 is much faster, its on par with HHVM in terms of speed, which was what PHP 5 failed to offer as compared to PHP 4(PHP 5 was faster than PHP 4, but not magnitudes faster). This may make the transition shorter than you have envisioned.

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Instant Website Review

Use Woorank to analyze and optimize your website to improve your website to improve your ranking!

Run a review to see how your site can improve across 70+ metrics!

Get the latest in Front-end, once a week, for free.