Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

StackOverflow:
A Tale of Two Industries: How Programming Languages Differ Between Wealthy and Develo
Sep 01, 2017 @ 12:44:03

On the StackOverflow blog there's an interesting post that looks at the differences in programming languages between countries based on their current state, either a developing country or a wealthy one (or somewhere in between).

Here at Stack Overflow, we’re interested in using our data to share insights about the worldwide software development community. [...] This leads us to wonder how else programming technologies may differ between rich and poor countries, and how that affects our picture of the global software development industry. In this post, we’ll explore these differences, and show that’s it’s useful to segment the software development industry into high-income countries and the rest of the world.

All the analyses explored here were performed on 2017 so far (January-August), on the 250 tags that had the most traffic during that time.

They investigated some of the major programming languages and platforms (including PHP) and found some interesting negative and positive correlation results. The post then covers how they split the list of countries in two (wealthy vs developing) and show results of the technologies they use. They include graphs for each of the points they make and link over to their StackOverflow Insights site where you can gather statistics for evaluation of your own.

tagged: stackoverflow programming language country difference statistics

Link: https://stackoverflow.blog/2017/08/29/tale-two-industries-programming-languages-differ-wealthy-developing-countries/

Exakat Blog:
Moving from array to class
Apr 12, 2017 @ 11:18:42

In a new post to the Exakat blog there's a proposal to replace uses of arrays with classes to make scripts more efficient and handle resources better behind the scenes.

Ever since I started using PHP, arrays have always been my friend. They are versatile, they have a wide range of functions, and they are easy to use. I kept using them versions after versions, and even with PHP 7.2, I still rely on them a lot. Over the years, classes have also made their way into my toolset. They have a different usage : classes are for complex data structures, for business logic. Simple data structures get an array. Until we tried what seemed impossible : a moving from an array to a class.

He mentions some of the recent changes in PHP 7 that make the use of classes over arrays a bit more advantageous. He then gets into how to take advantage of these efficiency benefits in moving from arrays to classes. He uses an example from his own work in the Exacat engine, how he performed the replacement and a small caveat he found when working with functions requiring array input. He ends the post with some of the other benefits from making the move including performance enhancements, readability and reduced memory usage.

tagged: array class performance difference tutorial php7

Link: https://www.exakat.io/moving-from-array-to-class/

Adam Wathan:
Methods Are Affordances, Not Abilities
Jan 25, 2017 @ 09:58:45

Adam Wathan has a new post on his site about a different way of thinking he's coming around to about methods, affordances and abilities.

In one of my current projects, I needed to be able to broadcast email announcements to all of the users in the system. If you've read about enough patterns and principles, there's a decent chance you saw [the line allowing an Announcement to perform the "broadcast" operation] and immediately thought to yourself: "What?! An announcement shouldn't be able to broadcast itself!"

I used to think that too, but over the last few years I've started to think differently.

He talks about "do-er" classes that normally would take in something like an announcement and perform the operation to broadcast it. He suggests that this comes from a misunderstanding about the point of methods: abilities versus things you could do with an object. He goes on to give some examples of double standards with DateTime handling, the complexity it could introduce and how, despite it sounding like an immediate action, the "broadcast" method could just be deferring to a background queue anyway.

tagged: methods affordance ability difference misunderstanding thinking opinion

Link: https://adamwathan.me/2017/01/24/methods-are-affordances-not-abilities/

Stefan Koopmanschap:
Command or Controller
Jun 20, 2016 @ 12:04:18

In a post to his site Stefan Koopmanschap takes a look at the technical term "command" and tries to clear up some of the confusion around its use and how it differs from the idea of a "controller".

A couple of weeks ago while walking towards lunch with Jelrik we were having a bit of a discussion about the use of the term Command. Not long before that, Jelrik had asked a question about naming of Commands in our Slack channel, which led to some confusion.

He starts off by defining what a command is and why it's called a "command" instead of a controller (hint: it "just works" with the Symfony Console). He then gives an example of a command in a Symfony bundle structure and how a CLI "controller" can extend the Command and automatically be integrated into the command structure.

tagged: command controller clarification example difference symfony bundle

Link: http://leftontheweb.com/blog/2016/06/18/Command-or-Controller/

SitePoint PHP Blog:
Finding Differences in Images with PHP
May 26, 2016 @ 10:56:33

The SitePoint PHP blog has posted a new tutorial from author Christopher Pitt on an interesting topic that could come in very handy in the right situations: finding differences in images with PHP.

I recently stumbled across a fascinating question: how could I tell whether an image had changed significantly? As PHP developers, the most troublesome image problem we have to deal with is how to resize an upload with an acceptable loss of quality. In the end I discovered what many before me have – that this problem becomes relatively simple given the application of some fundamental mathematical principles.

He starts off by talking about images as "bitmaps", basically a collection of pixels composed in a grid. He also mentions images as sets of vectors, but in PHP the bitmap approach is simpler and more understandable. He includes some code showing the breakdown of an image into its RBG colors values and what the data represents. He then moves into measuring the distance "in three dimensions" with a bit of geometry and applies them to a simple State class. This class breaks down the image given into RBG details then, eventually, compares the other image based on the euclidean distance between the points on the original and the ones from the new image. He filters some of these results through a standard deviation view to weed out problems with almost identical images.

tagged: image difference evaluation tutorial gd similar euclideandistance standarddeviation

Link: https://www.sitepoint.com/finding-differences-in-images-with-php/

Jeff Madsen:
Eloquent Create, Update, New...the Untold Story 2016-04-01
Apr 06, 2016 @ 12:19:20

Jeff Madsen has a quick post to his site with the "untold story" behind Eloquent's save and create in the Laravel framework.

Over on Laravel Quick Tips we've been looking at a few of these functions and their uses, and I thought it might be helpful to collect all of them together in a single (I hope) coherent post.

Without further preamble, let's get to it. I'm going to use the basic User object and table that ships with a default installation of Laravel so you can follow along if you like.

He starts with the difference between "new" and "create", pointing out the one fundamental difference: one saves, one does not. He then looks at some of the other new/create functions (like findOrNew, firstOrCreate, updateOrCreate), what each of them does in the background and a quick snippet of code showing.

tagged: eloquent laravel create update new behindthescenes difference save

Link: http://codebyjeff.com/blog/2016/04/eloquent-create-update-new-the-untold-story

Derick Rethans:
New MongoDB Drivers for PHP and HHVM: Cursor Behaviour
Mar 08, 2016 @ 11:52:14

Derick Rethans has posted the next part of his series looking at the new an improved MongoDB drivers for PHP in this post to his site. This time he focuses on the updates to cursor behavior from the previous versions.

We released a new version of the MongoDB driver for PHP (the mongodb extension) near the end of last year. In a previous blog post, I covered the back story of the how and why we undertook this effort. And in another post, I spoke about the architecture of the new driver. In this episode I will discuss changes in cursor behaviour.

I recently found the following comment added to the driver's documentation, on PHP.net, which read: "I noticed that ->sort is missing from the cursor. Seems like the old driver has more functionality."

The new driver certainly allows for sorting of results of queries, but no longer by calling the sort() method on the cursor object. This is because cursors are now created differently than in the old mongo extension.

He starts by talking about how the legacy driver handled its cursor functionality and when it actually performed the data lookup (hint: not until used). In the newer drivers the cursor request is made when the object is created. Because of this change, actions like "sort" and "skip" have to be sent as options on the query instead.

tagged: mongodb drivers hhvm cursor behavior difference version

Link: https://derickrethans.nl/new-drivers-part3-cursor.html

Reddit.com:
What is the difference between a framework and a library?
Dec 30, 2015 @ 11:34:10

On Reddit.com's /r/php subreddit there's a discussion that's started up around this video that proposes some of the differences between a framework and a library.

Many people have asked me this question before. It's sometimes hard to get a straight answer, but if we remove all of moot details, use cases, and focus simply on the architectural design details the difference becomes quite clear. This video attempts to explain this difference in a relatively simple and straight-forward manner.

The conversation doesn't just talk about PHP frameworks specifically. There's also some mention of things like jQuery from other programming communities. There's plenty of suggested definitions in the conversation but most revolve around two ideas: that the library is a "tool" to use when needed and the framework is the structure of the application (hence "framework") that "uses you".

tagged: framework library difference video youtube discussion

Link: https://www.reddit.com/r/PHP/comments/3yei0q/what_is_the_difference_between_a_framework_and_a/

php[architect]:
May 2014 Issue Released - Making a Difference
May 20, 2014 @ 12:20:43

php[architect] has announced the release of the latest edition of their magazine, the May 2014 edition: "Making a Difference".

Our May issue is now available. While it’s easy to focus on our own needs and tasks, in this issue, we look at how you Make a Difference and bank some karma too.

Articles in this issue include:

  • Joe Devon covering Global Accessibility Awareness Day
  • Michael Crumm on working with Guzzle and APIs
  • Aaron Saray looking at filter_var and other built-in functions
  • Matthew Setter finishes up his Phalcon introduction

You can pick up your copy of this month's magazine either as a single issue or as a part of a yearly (print or PDF...or both!) subscription.

tagged: phparchitect may2014 issue release make difference

Link: http://www.phparch.com/2014/05/may-2014-phparchitect-magazine-released-making-a-difference/

Konstantin Kudryashov:
Conceptual difference between Mockery and Prophecy
Jan 14, 2014 @ 10:47:20

In a new post to his site today Konstantin Kudryashov takes a look at two PHP testing tools and the differences/similarities between them - Mockery and Prophecy. Mockery is a mocking tool created by Pádraic Brady to make mocking simpler and Prophecy is more of a mocking framework, both for use in PHP unit testing.

Today I’ve been asked twice what’s the difference between Mockery and Prophecy just to suddenly discover that I didn’t clarify this aspect never before. Well, that’s about time. If we were to remove all the syntactical and implementation differences between two libraries what we’ll be left with is one really big conceptual difference and it’s the fact that in contradiction to Mockery, Prophecy puts messaging (aka how objects communicate) before structure (aka when objects communicate).

He starts with a sample class (the usual "calculator" example) and shows how it would look to mock it out with each tool, setting return values for both the "getRating" and "setRating" methods. He enhances the tests a bit more to include an event dispatcher and raising an event. The approach is similar, but Prophecy uses something called "message binding" to more effectively handle changes to the class under test.

tagged: difference mockery prophecy unittest mocking framework

Link: http://everzet.com/post/72910908762/conceptual-difference-between-mockery-and-prophecy